Request.form in ascx file

Results 1 to 2 of 2

Thread: Request.form in ascx file

  1. #1
    Join Date
    Dec 1969

    Default Request.form in ascx file

    Can you use request.form in a user control (ASCX) file?<BR><BR>I have made a simple example one where I have an &#060;asp:dropdownlist&#062;<BR><BR>and then have a button which onclick shows the selected value from the list in an &#060;asp:label&#062;<BR><BR>This works in an ASPX but not an ASCX<BR><BR>is that the expected behaviour and if so why?

  2. #2
    Join Date
    Dec 1969

    Default RE: Request.form in ascx file

    You&#039;re not supposed to reference server side controls using Request.Form anymore. The dot net way is to use MyDropDownList.SelectedItem.Value<BR><BR>If you are putting the dropdown in a user control, you need to make a Public Property that you can reference outside the Control.<BR><BR>Public ReadOnly Property SelectedItemValue As String<BR> Get<BR> Return MyDropDownList.SelectedItem.Value<BR> End Get<BR>End Property<BR><BR><BR>From the aspx page:<BR>Response.Write("You selected: ")<BR>Response.Write(MyUserControl.SelectedItemVal ue)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts