0

I have a HiddenField which changes value depending on what the user clicks. On the same page I have an invisible Panel with a User Control inside of it. I want to pass this value to the control when the Panel becomes visible.

The code:

<asp:HiddenField ID="hfdSelectedDeliveryAddressID" runat="server" Value="0" />
<asp:Panel ID="pnlOrder" runat="server" Visible="false">
    <uc3:AddressBook ID="AddressBook1" runat="server" AddressID="[value]" />
</asp:Panel>

I guess I'm asking what the syntax is to insert $("#<%= hfdSelectedDeliveryAddressID.ClientID %>").val() where "[value]" is. Help?

2 Answers 2

1

With Visible="false" set, you must be going back to the server to set Visible = true, right? When you set Visible = true, set the property as well:

AddressBook1.AddressID = hfdSelectedDeliveryAddressID.Value;
AddressBook1.Visible = true;
Sign up to request clarification or add additional context in comments.

Comments

0

I'm assuming you're using jquery due to the fact you have

$("#<%= hfdSelectedDeliveryAddressID.ClientID %>").val()

You can use

var value = $("#<%= hfdSelectedDeliveryAddressID.ClientID %>").val();
$("#<%= AddressBook1.ClientID %>").attr("AddressID", value)

.attr() sets the attribute specified by the first parameter ("AddressID" in this case) with the value specified in the second parameter (the value of your hidden field in this case).

Hope it helps.

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.