Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

declaring user control in code behind

Status
Not open for further replies.

gagz

Programmer
Nov 21, 2002
333
US
Someone must have run into this before...

I user codebehind (ie setting src and inherits attribute of page declarative). When I use spaghetti code, its easy to register my user control, set the element up in html, then get the value in my script blocks on post back (set with a public property of the user control). However, when i register the control, and set it up in html on my aspx page, then try to access it on my .vb code behind, I'm having issues... Here's pretty much what i'm doing and what i've done:

webform.aspx:
Code:
<%@ Register TagPrefix=&quot;COUNTRIES&quot; TagName=&quot;CountryList&quot; Src=&quot;/bmc/Library/countries.ascx&quot; %>
<%@ Register TagPrefix=&quot;STATES&quot; TagName=&quot;StateList&quot; Src=&quot;/bmc/Library/states.ascx&quot; %>
and
Code:
<STATES:StateList id=&quot;StateList1&quot; runat=&quot;server&quot;></STATES:StateList>
<COUNTRIES:CountryList id=&quot;CountryList1&quot; runat=&quot;server&quot;></COUNTRIES:CountryList>

and in webform.aspx.vb, i've tried:
Code:
Protected WithEvents StateList1 As System.Web.UI.UserControl.StateList
 Protected WithEvents CountryList1 As System.Web.UI.UserControl.CountryList
and
Code:
Protected WithEvents StateList1 As System.Web.UI.UserControl
 Protected WithEvents CountryList1 As System.Web.UI.UserControl
and
Code:
Protected WithEvents StateList1 As StateList
Protected WithEvents CountryList1 As CountryList

the closest i've gotten is with try #1, in which i receive the following error:
Code:
Compiler Error Message: BC30002: Type 'System.Web.UI.UserControl.StateList' is not defined.

Source Error:

 

Line 28:         Protected WithEvents txtFaxNum As System.Web.UI.WebControls.Textbox
Line 29:         Protected WithEvents ddIndustry As System.Web.UI.WebControls.DropDownList
Line 30: Protected WithEvents StateList1As System.Web.UI.UserControl.StateList
Code:
Line 31:         Protected WithEvents CountryList1 As System.Web.UI.UserControl.CountryList
Line 32:


HELP! Thanks.
 
There's a blurb in this thread that should get you going.

thread855-288280

ps. I think I put in there to add it to the controls collection of a label. I'm revising that to the controls collection of a placeholder. That's what those are used for.

-paul
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top