|
-
Nov 2nd, 2004, 01:55 AM
#1
Thread Starter
Hyperactive Member
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
-
Nov 3rd, 2004, 01:48 AM
#2
Thread Starter
Hyperactive Member
-
Nov 3rd, 2004, 01:36 PM
#3
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|