Asp.net中支持輸出時(shí)用html控制樣式
Response.Write("<font size=3px color=blue>");
Response.Write("用戶名:"+username.Value+"密碼:"+pwd.Value);
Response.Write("</font>");
可以在Page_Load中初始化下拉列表框的數(shù)據(jù)
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 1; i < 150; i++)
{
ddlage.Items.Add(new ListItem(i.ToString()));
}
}
用來(lái)設(shè)置方向問(wèn)題
CheckBoxList1.RepeatDirection = RepeatDirection.Vertical;//水平方向
Horizontal//垂直方向
遍歷checkbox選項(xiàng)組
foreach (ListItem item in CheckBoxList1.Items)
{
if (item.Selected)
{
result += item.Text + "<br/>";
}
}
上傳文件
string filename=fileupload.PostedFile.FileName;
int fileLength = fileupload.PostedFile.ContentLength;
fileupload.PostedFile.SaveAs(HttpRuntime.AppDomainAppPath + @"Upload\" + FileName.Text.Trim() + filename.Substring(filename.LastIndexOf('.')));重命名文件
protected void Button1_Click(object sender, System.EventArgs e)
{
if (File1.PostedFile != null)
{
//上傳文件的文件名(含完整路徑)
string fileName = File1.PostedFile.FileName ;
//上傳文件的大?。╞yte)
int fileLength = File1.PostedFile.ContentLength ;
string sMsg = null;
//判斷文件大小是否超過(guò)200K
if (fileLength > (1024*1024))
{
sMsg = fileName + "文件超過(guò)200K字節(jié)!";
}
else
{
//取文件名
fileName = fileName.Substring (fileName.LastIndexOf (@"\"));
//使用SaveAs方法,將文件保存在項(xiàng)目路徑\upload目錄下
File1.PostedFile.SaveAs (HttpRuntime.AppDomainAppPath + @"upload\" + fileName);
sMsg = "成功上傳文件:" + fileName + "文件大?。? + fileLength + "字節(jié)" + "文件類型:" + File1.PostedFile.ContentType ;
}
//使用JavaScript顯示操作結(jié)果信息
Response.Write ("<script language='JavaScript'>window.alert('" + sMsg + "');</script>");
}
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。