当使用UPDATE PANEL时,应用程序不显示javascript消息
Application does not shows javascript message when UPDATE PANEL is used
我正在制作ASP。. NET应用程序(c#)。[Visual Studio 2010]
当我尝试使用javascript使用客户端消息时,它会在未使用更新面板时显示消息。
但是当我在我的应用程序中添加了更新面板以防止它回发时,它不会在插入记录时显示我这样的javascript消息
在下面的方式我试图显示消息:
Response.Write("<head><script type='text/javascript'>alert('Member Registered Sucessfully')</script></head>");
我代码: try
{
con.Open();
cmd = new SqlCommand("insert into register values(@name,@city,@address,@mobile)",con);
cmd.Parameters.AddWithValue("@name",txtName.Text);
cmd.Parameters.AddWithValue("@city", ddlCity.Text);
cmd.Parameters.AddWithValue("@address",txtAddress.Text);
cmd.Parameters.AddWithValue("@mobile", txtMobile.Text);
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
int res=cmd.ExecuteNonQuery();
if (res > 0)
{
Response.Write("<head><script type='text/javascript'>alert('Member Registered Sucessfully')</script></head>");
}
else
{
Response.Write("<head><script type='text/javascript'>alert('Member Not Registered Sucessfully')</script></head>");
}
con.Close();
}
请告诉我这是在哪儿做的。
如果您有更新面板,请使用ScriptManager.RegisterClientScriptBlock
ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Member Registered Sucessfully');", true)
在异步回发期间不能使用Response.Write
相关文章:
- 使用电话间隙在Android应用程序中显示SQL Lite的数据
- Windows8应用程序(html&Javascript):从图片库(除了文件选择器)显示图像的另一种方式
- angularjs+rails应用程序中未显示模板
- 使用谷歌应用程序脚本从工作表中获取值并将其显示在文本框中
- 谷歌图表在运行应用程序时只能显示一次
- 应用程序在呈现Jquery Mobile之前显示无样式的Html
- 如何下载图像并将其显示在NativeScript应用程序中
- 为我的rails应用程序显示javascript弹出消息
- 无法在Chrome(打包)应用程序上检测到ESC按钮(全屏显示时)
- InvalidOperationException:当应用程序未在UserInteractive模式下运行时显示模式对话
- 如何将外部 css/js 文件提供给 NodeJS 应用程序显示的 html 文件
- PhoneGap应用程序显示旧的iOS 6键盘和旧的选择器
- 根据课程 GPS 应用程序显示图像
- Socket.io 聊天应用程序显示检测到的事件发射器内存泄漏.添加了 11 位听众.使用 emitter.setMax
- 用于在移动网站上向移动应用程序显示横幅的JavaScript库
- Web应用程序显示'é'像�.
- iOS Web应用程序-显示内容,只有添加到主屏幕
- 在谷歌chrome 32中打开angularjs应用程序显示空白页面
- 在 AppHarbor 上托管 asp.net Web API 的 Angular Web 应用程序显示错误的网页
- 将图标放在html5应用程序显示之前