开发者

ASP.NET/HTML: Use ASP.NET's label text/value in HTML's input value

开发者 https://www.devze.com 2023-01-03 00:33 出处:网络
I have the following html codes (to be used in 开发者_如何学PythonPOST method): // from Default.aspx

I have the following html codes (to be used in 开发者_如何学PythonPOST method):

// from Default.aspx
<input type="hidden" name="lblName" value="John" />
<input type="hidden" name="price" value="100.00" />

Is it possible to change the 'value' part by using the value/text ASP.NET label given below:

//from Default.aspx.cs
<asp:Label ID="lblName" runat="server" Text="John" />
<asp:Label ID="lblPrice" runat="server" Text="100.00" />

I just want to find a way to retrieve 'value' data dynamically coming from the ASP.NET label. Any suggestions?


Why not using a server side hidden control whose values could be modified dynamically from the server side:

<asp:HiddenField ID="lblName" runat="server" Value="John" />

Another possibility is to perform this on the client side using javascript: labels are usually rendered as span tags, so you will need to obtain the proper span by id and then assign it's innerHTML value to the hidden element. Using a javascript framework like jQuery might render this task much easier and guaranteed to work cross browser.

0

精彩评论

暂无评论...
验证码 换一张
取 消