Jump to content
  • Advertisement
Sign in to follow this  
ArchG

[web] Simple User Control Question [ANSWERED]

This topic is 4525 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have made a UserControl in ASP.net with the custom property ClientID. My only question (and I feel like an idiot asking) is how to assin this property with a variable. At first I thought I could just do
<Control:UserControl ID=UC1 Client_ID=<%iClientID%> runat=server />
But you can't use the <% %> brackets inside a runat=server thinger. Next I thought I could change the property with javascript. (Another stupid thought) by using a simple
document.getElementById('UC1').Client_ID = iClientID;
But of course that didn't work because javascript can't access that server stuff. So I'm asking you guys now. How can I assign a variable to a UserControl Property? Thanks, ArchG [Edited by - ArchG on January 4, 2006 2:52:55 PM]

Share this post


Link to post
Share on other sites
Advertisement
The thing that you have to understand, is that you can't script server-side controls using client-side script. That's a definite no-no.

I would have thought you should be able to use <%= in an attribute value though. Try using

<%= iClientID %>

instead.

Failing that, create a member variable for the control in the codebehind class and set the property value in the Page_Load event handler.

Mark

Share this post


Link to post
Share on other sites
Yeah, apparently you can't have <% %> blocks in a server side tag..(says the error message).

The reason that it didn't work before in the PageLoad section is I didn't know to use the ID as the prefix. I tried using the TagName and the Prefix as a prefix, but neither of those worked.

Thanks Markr

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!