Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

c#,asp.net-passing data to a control

Hi,
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" />
</div>

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?
Thanks
0
CharlieDev
Asked:
CharlieDev
  • 2
  • 2
1 Solution
 
HarryNSCommented:
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.
0
 
CharlieDevAuthor Commented:
I can see that the hatID in the aspx page is being assigned the correct guid! It wont transfer over to the control though!
0
 
wht1986Commented:
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
0
 
wht1986Commented:
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); }
}
0
 
CharlieDevAuthor Commented:
thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now