我想通过JavaScript从页面后面的aspx代码提供消息 [英] I want to provide message through JavaScript from aspx code behind page

查看:76
本文介绍了我想通过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);
}

推荐答案

这可能适合你:



This might work for you:

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


如果它不起作用,那么你也可以试试这个:



If it is not working then you can try this as well:

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>





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



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



如果有帮助你接受答案



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代码提供消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆