如何在处理程序中调用JavaScript [英] how to call javascript in handler

查看:86
本文介绍了如何在处理程序中调用JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在点网应用程序的http处理程序中调用javascript

how to call javascript in http handler in dot net application

推荐答案

您好,Sanjay,

您可以通过以下两种简单方法之一来实现此目的:

第一个是使用Response.Write()
如果要使页面显示一些警报,则可以使用以下单行代码进行操作:
Hi Sanjay,

You can achieve the purpose by doing one of the two easy ways:

The first one is to use Response.Write()
If you want to cause the page to display some alerts then you can do with this single line of code:
Response.Write("<script>alert('alert message');</script>");



第二个是使用ClientScript.RegisterClientScriptBlock
如果要让方法后面的代码调用aspx或单独的js文件中某个地方引用的任何JavaScript方法,则应使用ClientScript为您执行以下操作:



The second one is to use ClientScript.RegisterClientScriptBlock
If you want the code behind method to call any JavaScript Method referenced somewhere in your aspx or in a separate js file you should use ClientScript to do this for you like below:

Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "AnyNameForScriptBlock", "NameOfJavaScriptMethod()", true);




希望这会有所帮助!
快乐编码:)

Sunny K




Hope this helps!
Happy Coding:)

Sunny K


这篇关于如何在处理程序中调用JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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