Refering to <asp:> webcontrols

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

  1. #1

    Default Refering to <asp:> webcontrols

    Hey,

    Question, how can i create client-side javascript that refers to a asp.net
    webcontrol. For example set the focus of a textbox lik this.

    <asp: TextBox ID="Textbox1" />

    (client side)
    <script javascript>
    Textbox1.focus();
    </script>

    this wont't work, couse the webcontrol textbox1 has a diferent ID in the
    actualy create HTML output. How can i solve this problem..

    Thanks.

    Henk

    henk Guest

  2. Similar Questions and Discussions

    1. refering to dynamic movie clip instances
      I have been developing a flash movie where movie clips can be dragged to a certain position over another movie clip. When the movie clip is dragged...
    2. How to jump from "Tween" Entry in library to refering Timeline element ?
      After having loaded a certain *.fla source into Flash MX I open the library and click on a certain Tween entry. Then I want to let Flash display...
    3. Getting refering page
      I've found many references to this while googling around, but no definite answers. I'm wanting to get the refering page information in a perl/cgi...
    4. IE WebControls
      Hi, Downloaded IEWebControls.exe application & run on local machine O/S: Win Advance Server 2000 Framework: 1.1 Notes: * During installation...
    5. WebControls enumeration
      Is there enumeration for the WebControls? Thanks.
  3. #2

    Default Re: Refering to <asp:> webcontrols

    henk wrote:
    > Hey,
    >
    > Question, how can i create client-side javascript that refers to a
    > asp.net webcontrol. For example set the focus of a textbox lik this.
    >
    > <asp: TextBox ID="Textbox1" />
    >
    > (client side)
    > <script javascript>
    > Textbox1.focus();
    > </script>
    >
    > this wont't work, couse the webcontrol textbox1 has a diferent ID in the
    > actualy create HTML output. How can i solve this problem..
    >
    > Thanks.
    >
    > Henk
    You can generate the javascript server side:

    "<script type='text/javascript'>" + Textbox1.ClientID +
    ".focus();</script>";
    Ray Booysen Guest

  4. #3

    Default Re: Refering to <asp:> webcontrols

    Try this one:

    document.getElementById("<%=TextBox1.ClientID%>"). focus();


    "henk" <henkenboukje@versatel.nl> wrote in message news:7d8f$44cb5d10$52adce4b$20735@news.versatel.ne t...
    > Hey,
    >
    > Question, how can i create client-side javascript that refers to a asp.net
    > webcontrol. For example set the focus of a textbox lik this.
    >
    > <asp: TextBox ID="Textbox1" />
    >
    > (client side)
    > <script javascript>
    > Textbox1.focus();
    > </script>
    >
    > this wont't work, couse the webcontrol textbox1 has a diferent ID in the
    > actualy create HTML output. How can i solve this problem..
    >
    > Thanks.
    >
    > Henk
    >
    Dmitry Nechipor. [MCDBA] Guest

  5. #4

    Default Re: Refering to <asp:> webcontrols

    What I have done is insert some Javascript to set the value for the ID of
    the control. I start with this static Javascript.

    var controlId;

    function setControlId(id)
    {
    controlId = id;
    }

    Then I use Page.ClientScript.RegisterClientScriptBlock to add this code...

    string script = "setControlId('" + textbox1.ClientId + "');";

    You can then have the client script wrapped automatically with the script
    tags when it is registered. Then you just use the value for the controlId
    in the rest of your Javascript.

    Brennan Stehling
    [url]http://brennan.offwhite.net/blog/[/url]

    "henk" <henkenboukje@versatel.nl> wrote in message
    news:7d8f$44cb5d10$52adce4b$20735@news.versatel.ne t...
    > Hey,
    >
    > Question, how can i create client-side javascript that refers to a asp.net
    > webcontrol. For example set the focus of a textbox lik this.
    >
    > <asp: TextBox ID="Textbox1" />
    >
    > (client side)
    > <script javascript>
    > Textbox1.focus();
    > </script>
    >
    > this wont't work, couse the webcontrol textbox1 has a diferent ID in the
    > actualy create HTML output. How can i solve this problem..
    >
    > Thanks.
    >
    > Henk

    msnews 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