Reputation: 1171
I am trying to assign a asp.net label using JavaScript and then whenever label text get changed to trigger Ajax UpdatePanal and update a grid based on text in the label.
This is what I have currently tried:
`function ChangeTeam(sPARENT_ID, sPARENT_NAME) { alert("me1"); document.getElementById("Label4").value = "Text 123"; document.forms[0].submit(); } function PopupHelp(page) { var url = page; window.open(url,'Select','width=600,height=600,status=0,resizable=1,scrollbars=1,toolbar=0,location=1'); }'
So what this is actually doing is: User click on a button under PAGE1 a new windows opens with PAGE2, PAGE2 contains checkboxes for user to select, once the user has made the selection on PAGE2 the selection ID is passed via JavaScript back to PAGE1 CHANAGETEAM() function where that function should populate a hidden label "Label4" and then based on that population of the label Ajax Panel should trigger and update a grid with the ID selected.
With the code I have above it gets back into CHANGETEAM() function and sends that alert ME1 but looks like nothing past that works. What am I doing wrong?
Thanks for your help.
Upvotes: 1
Views: 1467
Reputation: 764
The way .NET's controls are named on the page vs their IDs how they're rendered are different. If you inspect the source code of the rendered page, it's probably something along the lines of UpdatePanel1_Label4 instead of just Label4.
Besides hardcoding that name in, you can also get the rendered Id with the ClientId Property. So your code can look like
document.getElementById('<%= Label4.ClientID %>').value = "Text 123";
Upvotes: 1