使用jQuery设置一个asp.net标签的价值和ASP.NET访问它Page_Load事件 [英] setting value of an asp.net Label using jquery and Accessing it on Page_Load event in ASP.NET

查看:163
本文介绍了使用jQuery设置一个asp.net标签的价值和ASP.NET访问它Page_Load事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个有点进退两难这里,其实我有两个页面,一个是item.aspx,一个是details.aspx。现在我details.aspx有一个asp.net Label.I把名字的项目使用jQuery在页面的主体标签后标签上。
在details.aspx标签的页面加载显示项目的名称。它工作正常。
但后来我也要把值到后端,C#,其中Label.Text无法读取。
我检查使用Firebug值,跨度标签值为空,但标签显示在浏览器项目的名称。也许是因为网页加载事件发生第一次,然后jQuery的code被设置标签的项目名称。
我们可以有一些变通,以解决这个问题,这样我可以使用的Page_Load event.i的Label.Text值确实需要解决这个问题。谢谢。

i am in a bit dilemma here, actually i have two pages, one is item.aspx and one is details.aspx. Now i details.aspx there is an asp.net Label.I put the name of an item on that label using the jquery after the label in the body of the page. On page load of details.aspx the Label shows the name of the item. It works fine. but then i have to take the value to back end, c# , which the Label.Text is not able to read. When i checked the value using Firebug, the span label value is Empty but the label shows the name of item in browser. Maybe because page load event is happening first then the jquery code is setting the item name for the Label. Can we have some work around to fix that so that i can use the Label.Text value on Page_Load event.i really need to fix this. thanks.

推荐答案

由于@tymeJV说,Hiddenfield应该工作。

As @tymeJV said, Hiddenfield should work.

我不知道是否你设置的隐藏起来的document.ready提起值。

I'm not sure whether you're setting value of hidden filed in document.ready.

您可能要低于尝试。

<input type="hidden" id="hdnProductName" runat="server" readonly="readonly"/>

使其只读如上图所示,并分配价值客户端,它会保留值,你可以把它的服务器端以及

make it readonly as shown above and assign value client side and it will retain the value and you can have it server side as well.

这篇关于使用jQuery设置一个asp.net标签的价值和ASP.NET访问它Page_Load事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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