简体   繁体   中英

Server Side Read Label Client Change

I've got a bunch if labels that are changed as a user inputs data into a form of mine. The Labels are changes with js on the client side. I then after all the submission are in put use a vb script to pull the string values from these labels.

The problem is the vb net part is not reading the new values of these labels. Anyway I can get it to read the new values? I have over 40 labels. Thanks!

EDIT:

I've tried adding the following

on page

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

on client side js part the alert shows the correct value

       var NeedId=document.getElementById('NeedIDLabel').innerHTML;
        document.getElementById('Label2h').Value = NeedId;
        alert(document.getElementById('Label2h').Value);

On server side i add a msg box to show me value and its empty.

NeedID = Label2h.Value

Edit 2: worked with textbox

Serverside languages like C# and VB can only retrieve new values changed by javascript when the control is posted to the page. Labels are not posted when a form is submitted; therefore, you will have to use something along the lines of HiddenFields or TextBoxes which are posted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM