MasterPage中的ScriptManager [英] ScriptManager in MasterPage

查看:60
本文介绍了MasterPage中的ScriptManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


有人可以帮我弄清楚我的程序有什么问题吗?


我创建了一个使用的网站MasterPage ..以及利用和滥用AJAX功能的计划,我添加了ScriptManager来创建PageMethods。


这就是我做的:


1.我添加了ScriptManager和调用页面方法的JavaScript在MasterPage中...在< body>中使用Javascript < form>中的标记和ScriptManager标签。


2.在子窗体中,我创建了一个HTML图像组件,在OnClick事件中,它调用了调用PageMethod的JavaScript函数。



当我运行页面时,它根本不显示任何错误,但每次我点击图像组件(触发javascript函数)时,它会显示页面上的错误。在页面的左下方,所需的输出不显示。


您可能认为错误可能在代码上(可能是真的),但我尝试使用相同的代码而不使用MasterPage,它没有任何错误。


我们非常感谢任何建议和建议。谢谢。

解决方案

很可能这是一个JavScript错误。

您可以使用IE8或 FireFox的FireBug 工具来调试错误。


-Frinny

嗨Frinny!


感谢您的回复。


是的我同意你的看法很可能一个JavaScript错误。但是,为什么当我在一个页面中运行页面(不使用MasterPage)并使用相同的JavaScript函数时,它会顺利执行?这个错误也与MasterManager被放置在MasterPage中有什么关系吗?


顺便说一句,我将PageMethods放在一个继承System.Web.UI.Page的基类中,所有页面都继承了该基类。 (我这样做是因为在其他论坛中提到当使用MasterPage时PageMethods应放在BaseClass中)


谢谢。


你好krungkrung,


你能说出JavaScript的位置吗?函数是写的?


如果javascript函数是在UPDATEPANEL中编写的,那么脚本管理器有可能在将页面呈现给浏览器时丢弃了该函数。所以我建议将函数保存在单独的文件中并从后面的代码中注册脚本文件。


希望它有所帮助,


Sudev Gandhi


Hi all,

Can somebody help me figure out whats wrong with my program?

I created a site with the use of MasterPage..and with a plan of utilizing and abusing the capabilities of AJAX, I added the ScriptManager to create PageMethods.

Here''s what I did:

1. I added the "ScriptManager" and the "JavaScript that calls the page method" in MasterPage...with Javascript inside the <body> tag and ScriptManager inside the <form> tag.

2. In the "Child Form", I created a HTML image component, and in the OnClick event it calls the JavaScript function which calls the PageMethod.


When I run the page it doesnt display any errors at all, but everytime I click the image component(which triggers the javascript func)..it displays "Error on page" at the bottom left side of the page and the desired output don''t display.

You might be thinking that the error could be on the code(which probably true), but I tried the same code without using a MasterPage and it works without any error.

Any suggestion and advice will be very much appreciated. Thanks.

解决方案

It is very likely that this is a JavScript error.
You could use IE8 or FireFox''s FireBug tool to debug the error.

-Frinny


Hi Frinny!

Thanks for the reply.

Yeah I agree with you that it is very likely a JavaScript error. But why is it that, when I run the page in a single page(without using the MasterPage) and using the same JavaScript function, It executes smoothly? Isn''t the error also something to do with ''ScriptManager'' being placed in the MasterPage or something to that effect?

Btw, I placed the PageMethods inside a Base Class which inherits the System.Web.UI.Page and all pages inherits that Base Class. (I did this as it was mentioned in the other forum that PageMethods should be placed inside a BaseClass when using MasterPage)

Thanks.


Hi krungkrung,

Can you pl tell that where the "JavaScript" function is written?

If the javascript function is written within UPDATEPANEL then there is a chance that script manager has discarded that function while rendering the page to browser. So I''d suggest to keep the function in separate file and register script file from the code behind.

Hope it helps,

Sudev Gandhi


这篇关于MasterPage中的ScriptManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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