我想通过JavaScript从页面后面的aspx代码提供消息

我想通过JavaScript从页面后面的aspx代码提供消息

本文介绍了我想通过JavaScript从页面后面的aspx代码提供消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在执行波纹管代码之后通过JavaScript从最终块中的页面后面的aspx代码提供消息但脚本无法工作...

尝试

{

HttpContext.Current.Response.End();

}

catch(Exeption ex)

{

}

最后

{

string str =< script language = javascript> LoginError();< script> ;

Page.ClientScript.RegisterStartupScript(this.GetType(),str,str);

}

I want to provide message through JavaScript from aspx code behind page in final block after executing bellow code but script cant works...
try
{
HttpContext.Current.Response.End();
}
catch(Exeption ex)
{
}
finally
{
string str = "<script language=javascript>LoginError();<script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), str, str);
}

推荐答案

ScriptManager.RegisterStartupScript(this,GetType(),"alertmsg","alert('hahahahah');",true);


Page.ClientScript.RegisterStartupScript(this.GetType(), "alertmsg", "alert('hahahahah');", true);





但请记住,您设计的页面必须有一个< form>< / form>用runat =server标记。



例如:





But remember one main thing that your designed page must have a <form></form> tag with runat="server".

for e.g:

<form id="form1" runat="server">
    <input id="rad1" type="radio" checked="checked" />
    <input id="rad2" type="radio" />
</form>





您可以查看我的文章,我也在申请中解释了同样的事情:



[]



如果有帮助你接受答案



You can check my Article, I had explained the same thing here also within an application:

http://www.c-sharpcorner.com/UploadFile/cd7c2e/call-jquery-from-code-behind-in-Asp-Net-application/[^]

Accept the Answer if it helps you


这篇关于我想通过JavaScript从页面后面的aspx代码提供消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 18:32