如何从处理程序调用javascript函数? [英] How to call javascript function from handler ?

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

问题描述

我已经在abc.cshtml页面编写了代码。我得到的是formName,fieldId,pType和finalMsg。



var pg = HttpContext.Current.CurrentHandler ;



pg.RegisterStartupScript(abc,< script type ='text / javascript'>

createErrorSpace(' + formName.ToString()+','+ fieldId.ToString()+','+ pType.ToString()+','+ finalMsg.ToString()+')

< / script>);





createErrorSpace是用config.js文件编写的。



但是我在这里得到错误所以请帮我急吗?



谢谢 -

I have written the code in abc.cshtml page.Here i am getting formName,fieldId,pType and finalMsg.

var pg = HttpContext.Current.CurrentHandler;

pg.RegisterStartupScript("abc", "<script type='text/javascript'>
createErrorSpace('" + formName.ToString() + "','" + fieldId.ToString() + "','" + pType.ToString() + "','" + finalMsg.ToString() + "')
</script>");


createErrorSpace is written in config.js file.

But I am getting error here so help me its urgent for me??

Thanks-

推荐答案

我在下一篇文章中有一些很好的例子:高级ASPX GridView分页和数据实体 [ ^ ]



首先阅读文章,然后再看看类的方法_ saveButton_Click()的源代码联系页面



在您的母版页(或页面布局)或页面中,您必须将refrenece包含在.js文件中,如下例所示:

I have some good examples in my next article: Advanced ASPX GridView Pagination and Data Entities[^]

Read the article first, then look also in the source code at the method _saveButton_Click() of the class ContactPage.

In your master page (or page layout) or page you have to include the refrenece to your .js file like in the next example:
<script src="/Scripts/config.js" type="text/javascript"></script>

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

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