本文介绍了从客户端脚本调用代码隐藏中的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在使用asp.net。 我想更新页面的一部分(不是整页)而不发送页面请求服务器。我想在客户端这样做。 为此,我想我应该使用AJAX和javascript。 我已经创建了一个处理程序页面:handler.ashx 我发送请求并以纯文本形式获得响应: (在javascript中) ... XMLHttpRequest.open(GET,url); XMLHttpRequest.onreadystate = ApplyUpdate; // ApplyUpdate是一个在客户端获取响应的函数(javascript)。 XMLHttpRequest.send(null); ... (在handler.ashx中) ... response.write(纯文本作为回应); ... 现在在ApplyUpdate函数中我可以使用纯文本并在客户端浏览器中显示它。 但是 问题是: 我在asp.net中有一个placeholder1控件:< asp:PlaceHolder ID =PlaceHolder1runat = server> 如何将纯文本(响应!)分配给标签控件并将标签添加到placeholder1控件中?? 我的意思是我如何在客户端使用这些代码: Label lb1 = new Lable(); lb1.text = plaintext; placeholder1.controls.add(lb1); 这些代码在c#中(代码隐藏)但我如何使用这些代码? 我不能通过javascript做同样的事情代码! 原谅我的错误解释。 我会感激任何帮助。Hi,I''m using asp.net.I want to update a part of my page (not whole page) without sending the page request to the server. I want to do this in the client side.for this, I think I should use AJAX and javascript.I''ve created a handler page: handler.ashxI send a request and get response in plain text:(in javascript)... XMLHttpRequest.open("GET", url); XMLHttpRequest.onreadystate = ApplyUpdate; // ApplyUpdate is a function that get the response in client side(javascript). XMLHttpRequest.send(null);...(in handler.ashx)... response.write("plain text as response");...Now in ApplyUpdate function I can use the plain text and show it in client browser.BUTthe problem is this:I have a placeholder1 control in asp.net: <asp:PlaceHolder ID="PlaceHolder1" runat="server">How can I assign the plain text (the response !) to a label control and add the label to placeholder1 control !?I mean how I can use these codes in client side: Label lb1 = new Lable(); lb1.text = plaintext; placeholder1.controls.add(lb1);these codes are in c# (code-behind) but how I can use such these codes?I cannot do the same thing by javascript codes !excuse my bad explanation.I''ll appreciate any help.推荐答案 这篇关于从客户端脚本调用代码隐藏中的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!