What namespace does such a control end up in

  • Thread starter Thread starter Cal Who
  • Start date Start date
C

Cal Who

I have a user control (.ascx) file that contains the VB as well as the
markup.
I haven't been able to specify a namespace in that file.
What namespace does such a control end up in?

And how do I reference it in a .vb file?

Thanks
 
Cal Who said:
I have a user control (.ascx) file that contains the VB as well as the
markup.
I haven't been able to specify a namespace in that file.
What namespace does such a control end up in?

And how do I reference it in a .vb file?

Thanks

A user control is just another class that will wind up in the same namespace
as the rest of your project. If you are using Visual Studio, all you have
to do is drag the .ascx file into an .aspx file at the spot that you want it
to go and it will place something like this at the top of the .aspx page's
code:

<%@ Register Src="ttsFooter.ascx" TagName="ttsFooter" TagPrefix="uc1" %>

Then, wherever you have actually placed the control on the page, you will
have something like this:

<uc1:ttsFooter ID="ttsFooter1" runat="server" />

You should not need to worry about namespaces.

-Scott
 
This is what works in the aspx file
<%@ Register TagPrefix="dp" TagName="DurationPicker"
Src="DurationPicker.ascx" %>
snip...
<dp:DurationPicker ID="dpicker" runat="server"
startDateTime='<%#Bind("Starttime") %>' endDateTime='<%#Bind("endtime") %>'
/>



When I try this in the code behind

Dim dpq As ASP.DurationPicker = CType(FormView1.FindControl("dpicker"),
ASP.DurationPicker)
dpq.startDateTime = Now
dpq.endDateTime = Now.AddHours(3)

And then publish I get :
E:\My Documents\Visual Studio
2008\WebSites\TEST\Calendar\EventsEdit.aspx.vb(34,0): error BC30002: Type
'ASP.DurationPicker' is not defined.

Strange thing is it works OK when I run it locally.That is the date and time
show they've been set.

Thanks
 
I believe that is similar to what I was doing but I tried it anyway by
adding this much:
Protected MyCtl As ASP.DurationPicker

Private Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles
MyBase.Init

MyCtl = DirectCast(FindControl("MyCtl"), ASP.DurationPicker)

End Sub

And got the same error for each ASP.DurationPicker.

The reason I asked about namespaces is that the IDE will not let me get away
with simply DurationPicker. It suggest I add the ASP prefix. Do you
understand why?

Maybe we should focus on the fact that it works OK, even if I debug and
watch dpq - it looks OK.

It's just when I publish the web site that the error shows up in the
recompile section.

What is different during the recompile?



Thanks
 
Back
Top