Results 1 to 3 of 3

Thread: User control values is not passing to DIV tag

  1. #1

    Thread Starter
    Hyperactive Member Kirun's Avatar
    Join Date
    Oct 2001
    Location
    Karachi , Pakistan
    Posts
    333

    Question User control values is not passing to DIV tag

    I have an ASP page myform.aspx where there is a user control in which there is a page name myform.ascx. And also beside user control i also have a div tag . I want to pass a value of the myform.ascx to the div tag.

    Actually its a search page . Searching is done on ascx page and i want to show the result count on the div tag.. how can i do this please help

  2. #2

    Thread Starter
    Hyperactive Member Kirun's Avatar
    Join Date
    Oct 2001
    Location
    Karachi , Pakistan
    Posts
    333

    Unhappy

    please help fellows !!

  3. #3
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    First off in the usercontrol you need to declare a public variable to hold this value you want to access, e.g. public resultcount as integer.
    Then presumably your code in the usercontrol will find your result count and you can set the public variable to this value.
    In your page code behind declare the usercontrol as other controls are declared.

    e.g. in a page's code you will see stuff like
    protected withevents label1 as label
    etc.
    add one in for your usercontrol with the same id it has in the html code
    protected withevents usercontrol1 as myform

    Now you can't access the usercontrol's variable until it has loaded and it will not have loaded in your page's load event. So you must override the page's prerender event and access it from there:-

    Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
    label1.text = usercontrol1.resultcount.tostring
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width