MessageBox无法正常工作 [英] MessageBox is not working
本文介绍了MessageBox无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我的MessageBox.show无法正常工作。亲切帮助
protected void Button3_Click( object sender,EventArgs e)
{
string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
int fileLengthInKB = FileUpload1.PostedFile.ContentLength;
if (FileUpload1.HasFile)
{
if (fileLengthInKB < 1048576 )
{
FileUpload1.PostedFile.SaveAs(Server.MapPath) ( 〜/ upload /)+ fileName);
Response.Redirect(Request.Url.AbsoluteUri);
}
else
{
MessageBox.Show( 输入小于1 MB的文件);
}
}
}
解决方案
我相信你遇到了麻烦,直到你得到了对MessageBox的正确引用...你没有注意到它是对Windows Forms的引用吗?!
MessageBox适用于桌面应用程序 - 你在网上的话!!! />
根据您的代码,您尝试验证文件大小 - 为什么不使用验证控件?
http://msdn.microsoft.com/en-us/library/debza5t0(v=vs.100).aspx [ ^ ]
你可以使用这个
ClientScript.RegisterStartupScript(this.GetType(),myalert,alert('Your Message');,true);
Hi Everyone,
My MessageBox.show is not working.Kindly help
protected void Button3_Click(object sender, EventArgs e)
{
string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
int fileLengthInKB = FileUpload1.PostedFile.ContentLength;
if (FileUpload1.HasFile)
{
if (fileLengthInKB < 1048576)
{
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/upload/") + fileName);
Response.Redirect(Request.Url.AbsoluteUri);
}
else
{
MessageBox.Show("Enter a file less than 1 MB");
}
}
}
解决方案
I believe you got some trouble until you got the right reference to MessageBox...Didn't you noticed that it's a reference to Windows Forms?!
MessageBox is for desktop application - you are in the word of web!!!
According to you code you try to validate file size - why not to use validation controls?
http://msdn.microsoft.com/en-us/library/debza5t0(v=vs.100).aspx[^]
You can use this
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Your Message');", true);
这篇关于MessageBox无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文