0

im trying this format:

$("#<%= hfWidth.UniqueID %>").val($("#drag").attr("offsetWidth"));

to fill the hidden field with client-side values

but when I do postback, the values doesn't seem to be saved.

help

3 Answers 3

3

If you want to get params from the server side, you should use name instead of id attribute.

And your code should work :

$("#elementId").val("value");
Sign up to request clarification or add additional context in comments.

2 Comments

the .UniqueID is the value set to the name attribute of the object.
Can you provide us more code than that ? Because this code doesn't show sufficient info. Thanks.
3

fixed it with <%= hfWidth.ClientID %>

2 Comments

This is only possible after 2 days.
yep.. im stuck with this for 2days... who ever made that stupid rule?
0

in your aspx page:

<asp:HiddenField ID="hdn_checkbox" runat="server" />

in your Javascript:

           function somefunction() {

                $("#<%= hdn_checkbox.ClientID %>").val("test");

            }

            $('.btnGreen').click(function () {

                somefunction();
                alert($("#<%= hdn_checkbox.ClientID %>").val());
                return true;
            });

Comments

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.