1

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.

1
  • Please post your HTML markup as well. Commented Feb 28, 2012 at 20:20

1 Answer 1

1

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";
Sign up to request clarification or add additional context in comments.

3 Comments

Got it thanks... That worked... Now how would I be able to incorporate ajax with this? so to only update that that grid instead of refreshing the whole page?
I don't see why this would have the whole page refresh.
I have the same problem Hey Nick. Did you figure out how to use ajax? Please let me know too ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.