只是问一个直接的问题,当我完成在我的页面中添加一些数据,然后单击提交按钮时,如何使一个弹出窗口说明信息已成功添加到数据库中而不是创建一个新的页?我有什么办法可以做?任何网站被引用?由于提交后弹出窗口
提交后弹出窗口
回答
你可以为它创建一个可重复使用的功能。
public void Show(string msg)
{
Page page = HttpContext.Current.Handler as Page;
if (page != null)
{
ScriptManager.RegisterStartupScript(page, page.GetType(), "msg", "alert('" + msg + "');", true);
}
}
并提交像这样的按钮调用。
protected void btnSubmit_Click(object sender, EventArgs e)
{
// Your Code for submit
Show("Save Success");
}
对于可重用函数的建议。 – freebird
你只是把下面的代码:
Response.Write("<script>alert('information has been successfully added')
</script>");
我认为使用Response.Write方法不是一个好的做法。 – freebird
你可以设置你的消息的标签文本并使其可见,当你要显示的消息。
lblMessage.Text = "Data updated successfully";
lblMessage.Visible = true;
为了使它突出,你可以使用jQuery dialogs,并与CSS样式它恰如其分。
//Global Declaration
public static void Message(String message, Control cntrl)
{
ScriptManager.RegisterStartupScript(cntrl, cntrl.GetType(), "alert", "alert('" + message + "');", true);
}
//Call any where, where you want to display message
Message("Any message here", this);
你可以编辑你的答案。有点令我困惑。谢谢:) –
ScriptManager.RegisterStartupScript(this, this.GetType(), "Notification", "alert('Done');", true);
使用ASP.NET你将仍处于一个完整的页面生命周期,如果你是一个经常提交行为提交表单。这意味着该页面首先需要重新加载,然后才能触发警报。如果你不想重新加载页面,而只是显示一个结果警报,你需要用AJAX执行你的操作,将表单发布到一个服务方法,该方法更新你拥有的数据库。这不会重新加载你的页面,只会显示你的ajax调用完成的提醒。 jQuery $.post()
在您点击按钮检查有效数据后,您可以使用ClientScriptManager.RegisterStartupScript Method
这里是你弹出
做这样的事情ClientScriptManager script = Page.ClientScript
if (!script.IsStartupScriptRegistered(GetType(), "Show Popup"))
{
script.RegisterStartupScript(GetType(), "Show Popup", "ShowPopup();", true);
}
您可以从code behind
调用javascript
功能
HTML:
<div id="Popup"></div>
CSS:
#Popup
{
height:200px;
width:300px;
position:fixed;
z-index:102;
left:50%;
top:50%;
margin-top:-130px;
margin-left:-180px;
font-weight:bold;
font-size:10pt;
padding:20px;
background-color:#fff;
border:10px solid #9cc3f7;
border-radius:20px;
-webkit-border-radius:20px;
-moz-border-radius:20px;
text-align:center;
display:none;
}
jQuery函数:
function ShowPopup()
{
$('#Popup').show("slow");
}
- 1. 提交表单后弹出窗口django
- 2. 在弹出窗口中提交表格
- 3. 将ajax提交到弹出窗口
- 4. 在弹出提交后刷新父窗口的整个框架
- 5. 如何在成功提交后关闭弹出窗口
- 6. 使用JavaScript弹出窗口提交表单提交
- 7. Html弹出窗体提交
- 8. 弹出窗体提交
- 9. 窗体弹出窗口和交互
- 10. Laravel:刷新页面弹出窗口'确认窗体提交'
- 11. 将Leaflet弹出窗口值插入窗体并提交
- 12. 使用zend框架从弹出窗口提交窗体到原始窗口
- 13. 弹出窗口
- 14. 弹出窗口然后退出
- 15. 如何在iframe窗口打开弹出窗口后将控制权交回
- 16. oauth在弹出窗口中登录后将控制权交还给父窗口
- 17. 如何在表单上创建弹出窗口提交
- 18. PBO-PAI-cycle中的隐式提交:也用于弹出窗口?
- 19. 提交在一个弹出窗口中创建的表单
- 20. 导入文件并在弹出窗口关闭时提交AngularJS
- 21. 在弹出窗口的父页面上提交表格
- 22. 如何将提交表单数据传递到弹出窗口
- 23. 显示一个css弹出窗口提交的表单之前
- 24. 提交表单内的弹出窗口不返回结果
- 25. 如何在提交信息前显示弹出窗口
- 26. 如何提交而不关闭丰富的弹出窗口?
- 27. 在HTML中弹出窗体提交
- 28. 弹出窗体提交崩溃IE9
- 29. 显示弹出式窗口后提交功能无法正常工作
- 30. Cmd提示计时器窗口弹出
您是否从答案中得到任何帮助? – freebird
还没有。我试图通过1 1的建议回答:) –