retrieve value from control

D

David J Duryea

Please if anyone can help, it would be greatly appreciated


I have a VB form on a page called create.aspx with some text fields and
listboxes.
I also have a control on the form

<%@ Register TagPrefix="UserControl" TagName="Categories"
Src="/Categories.ascx" %>

The Control Categories.ascx contains 2 listboxes CatID and SubCatID

The create.aspx page posts its values to a stored Proc. However I cannon
obtain the vaules from the listboxes on Categories.ascx.

I have tried
Request.Form("CatID")
CatID.SelectedItems.Value

If anyone can help I would appreciate it.

Thanks in advance.

Dave
 
A

Alessandro Zifiglio

hi dave, here is a quick copy and paste from the docs ;P

To set a property of a user control in a Web Forms page

Select the user control file in Solution Explorer and drag it onto your
page. Note the ID of the user control displayed in the page.
Press F7 to switch from Design view to the code-behind file.
In the Declarations area, add a line to declare the user control. For
example, for a user control of type WebUserControl1 whose ID is myControl1:
' Visual Basic
Public Class MyPage
Inherits System.Web.UI.Page
Protected myControl1 As WebUserControl1

// C#
public class MyPage : System.Web.UI.Page
{
protected WebUserControl1 myControl1;
Note The ID in the code-behind declaration must exactly match the ID for
the user control in Design view.
Now that you have a code declaration for the user control, all of the public
properties, methods, and events of your user control are available, and will
appear in the IntelliSense statement completion dropdowns.

Write code to call methods or set properties of your user control. For
example:
' Visual Basic
myControl1.Visible = True
myControl1.DataBind()

// C#
myControl1.Visible = true;
myControl1.DataBind();
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top