Passing parameters to user controls

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Passing parameters to user controls

    Hello.
    I'm having problem with passing parameters from .aspx file to user
    control.
    Could anyone tell me how to pass parameters from .aspx file to user
    control(.ascx) and how to recieve parameters at .ascx?
    Thank you for your help!
    Akira Guest

  2. Similar Questions and Discussions

    1. using javascript in User controls to access server controls of the user control
      Hello all, I have an asp.net textbox (named txtHidden) and an HtmlButton(named btnAction). I wanted to write a javascript function which will get...
    2. Passing Parameters to User Controls that are Dynamically Loaded in Placeholders
      Hi Guys, I have been having a big problem with trying to pass parameters into a user control when the user control is dynamically loaded into a...
    3. Loading controls dynamically + passing parameters
      Hi, I can use following syntax to add user controls directly to my pages : <XYZ:myControl parameter1="value1" parameter2="value2"...
    4. Passing parameters to Windows Controls
      Hi All, I have developed a windows forms user control, which I am going to host in Internet Explorer.. I am familiar with the security settings...
    5. Help Passing Parameters
      Before going to the third script I'd suggest storing the variables in session variables. Here's how I generally do login scripts. Perhaps have...
  3. #2

    Default Re: Passing parameters to user controls

    Open the CodeBehind file and add the user control to the controls
    collection. Not sure why, but, by default, a user control is placed on the
    page but never given a corresponding line in the CodeBehind file.

    Dim NameOfControlOnPage As MyControl
    protected MyControl NameOfControlOnPage;

    You can see the lines of other controls in your CodeBehind, so the above
    templates are suspect. Once you do this, you will be able to use:

    NameOfControlOnPage.PropertyOne = "";

    to set values.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    Author: ADO.NET and XML: ASP.NET on the Edge

    ************************************************** **************************
    ****
    Think Outside the Box!
    ************************************************** **************************
    ****
    "Akira" <akira@regonline.com> wrote in message
    news:3239e228.0307020936.20748177@posting.google.c om...
    > Hello.
    > I'm having problem with passing parameters from .aspx file to user
    > control.
    > Could anyone tell me how to pass parameters from .aspx file to user
    > control(.ascx) and how to recieve parameters at .ascx?
    > Thank you for your help!

    Cowboy \(Gregory A. Beamer\) Guest

  4. #3

    Default Re: Passing parameters to user controls

    use properties...or public fields :)

    user control:

    private _ValueID as integer
    Public Property ValueID as integer
    Get
    return _ValueID
    ENd Get
    Set (byval value as integer)
    _ValueID = value
    end set
    end property

    From within the user control you can simply refer to "ValueID" from
    thereonin to get the value that was assigned to it by the parent.


    Parent:
    Two methods
    <control:name runat="server" id="cntrl" ValueID=3 />

    in codebehind
    cntrl.ValueID = 3


    Karl

    "Akira" <akira@regonline.com> wrote in message
    news:3239e228.0307020936.20748177@posting.google.c om...
    > Hello.
    > I'm having problem with passing parameters from .aspx file to user
    > control.
    > Could anyone tell me how to pass parameters from .aspx file to user
    > control(.ascx) and how to recieve parameters at .ascx?
    > Thank you for your help!

    Karl Seguin Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139