DataBind Request.QueryString!!!

  • Thread starter Thread starter Adam Knight
  • Start date Start date
A

Adam Knight

Hi all,

I am trying to pass values to a user controls via the request.querystring
property.

The following syntax doesn't work, as i can response.write the values and
they exists.

<myLinks ID="LevelOne" intGroupID='<%# Request.QueryString("GroupID")%>'
intSectionID="1" intStandardID='<%# Request.QueryString("StandardID")%>'
strHeaderCss="LevelOneHeader" strContentBorder="LevelOneContent"
Runat="Server"/>

I have tested to see if these values do exists, which they do..they just
aren't being set in the user control.

I need to do this declaratively!!!

Any thoughts on what is going wrong??

Cheers,
Adam
 
Adam,

This is ASPNET news group. What you are doing is ASP. In asp.net you could
use the code behind features, well they've been around for a while give em a
try.

Here is the code behind for a simple control with a textbox that is
populated from the querry string when the control has been declaritively
setup in the aspx page.

Start by creating a public property in your control.
Then in the page_init method use your property to pull off the querry string.

Partial Class DeclaritiveControlExample_WebUserControl
Inherits System.Web.UI.UserControl

Public Property stringID() As String
Get
Return _stringID
End Get
Set(ByVal value As String)
_stringID = value
End Set
End Property
Private _stringID As String

Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
If Not stringID Is Nothing Then
TextBox1.Text = Request.QueryString(stringID)
End If
End Sub
End Class

In the aspx page the designer will support your public property by pressing
F4 or text assist.

<uc1:WebUserControl ID="WebUserControl1" runat="server"
stringID="intStringID" />

Good Luck
DWS
Got this to work then try adding attributes to your public property
add imports system.componentmodel to the user control class
and a category attribute to your property
<Category("Custom")> _
Public Property stringID() As String
rebuild website a couple times
Now in designer property editor the stringid will come up under "Custom"
 
Back
Top