c#, data to a control

Posted on 2009-04-20
Last Modified: 2012-05-06
I am trying to pass data to a control from an aspx page.
On the aspx page I have:

<div class="polaroid01">
      <HatPhotoControl:HatPic HatID='<%# GetRandomImageURL()%>' runat="server" />

GetRandomImageURL returns a guid for the HatID

The control page has:

 private Guid HatID;

    public string hatID
        get { return HatID.ToString(); }
        set { HatID = new Guid(value); }

But the guid isnt being transfered

Anyone see why?
Question by:CharlieDev
    LVL 6

    Expert Comment

    Can you check whether GUID is assigned when the aspx page calls GetRandomImageURL() method?

    Hardcode a server side property/variable value and check whether it is working from aspx page or not.

    Author Comment

    I can see that the hatID in the aspx page is being assigned the correct guid! It wont transfer over to the control though!
    LVL 12

    Expert Comment

    based on what you posted, I see case sensativity issue, try

    <HatPhotoControl:HatPic hatID='<%# GetRandomImageURL()%>' runat="server" />
    hatID starts lower case as the public property
    LVL 12

    Accepted Solution

    plus once you store grab the HatId in the control, how are you persisting it between postbacks?

    I would use something like

    public string hatID
        get {returtn (string)ViewState["HATID"]';}
        set{ViewState["HATID"] = value;}

    private Guid MyHatID
        get {return new Guid(this.hatID); }

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now