DataBind Request.QueryString!!!

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
 
G

Guest

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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,249
Latest member
KattieCort

Latest Threads

Top