admin管理员组文章数量:1315807
Hi i want to call a C# method.. I already tryed with webmethod, but in the c# method i will not have acces to textbox or others controls.
this is how i done without success.. .aspx
With static works, but i want without static, so i can access to the controls in the aspx and validate the page.
how can i do it?
Hi i want to call a C# method.. I already tryed with webmethod, but in the c# method i will not have acces to textbox or others controls.
this is how i done without success.. http://www.singingeels./Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx
With static works, but i want without static, so i can access to the controls in the aspx and validate the page.
how can i do it?
Share Improve this question asked Mar 26, 2010 at 11:46 LuisLuis 2,7159 gold badges44 silver badges72 bronze badges3 Answers
Reset to default 5You can't do this with just a javascript call, you need to postback if you want access to the controls on the page. The page doesn't know what's in the textboxes for example unless you send that data, which a javascript call won't do, but a form or AJAX submit will.
I'd suggest a javascript validation library, something like this. Just be sure to also validate on the server once you've submitted to check for users who have javascript disabled (or are maliciously trying to bypass your validation...).
You need to look at how to use an UpdatePanel, or a straight ajax callback.
With the UpdatePanel, you go through most of the page lifecycle, so you have access to the textboxes etc.
Using an UpdatePanel may be the simplest path to what you're trying to acplish.
<asp:ScriptManager runat="server">
<asp:UpdatePanel runat="server">
<ContentTemplate>
... your controls ...
</ContentTemplate>
</asp:UpdatePanel>
本文标签: Call a c method from JavascriptStack Overflow
版权声明:本文标题:Call a c# method from Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741989942a2408913.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论