Javascript in web user control

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

  1. #1

    Default Re: Javascript in web user control

    Anything that inherits from System.Web.UI.Control will have the read-only
    UniqueID property. You can use that get automatically generated id's from
    repeating things like DataList, DataGrid, Repeater, and presumably from your
    own control.

    HTH,
    Todd Thompson
    Todd Thompson 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. Passign Javascript From User Control to Parent(host) Page
      Good Afternoon I am hoping for some help for a problem i am struggling with. I am using a Parent Page to Dynamically load my user Controls based...
    3. embeding Javascript src attribute in User control
      I have a System.Web.UI.UserControl as custom control. I have a javascript block for user control. The problem is I want to bring src attribute from...
    4. can user control change its child control's property using javascript?
      Hi, I place a menu on the user control, and want center the menu based upon client's screen resolution. I try to check the resolution using...
    5. how can i add client side javascript to a web user control?
      hi, i have a web user control that i wish to add some client-side javascript to. something like this: onChange="javascript:DoSomething();" ...
  3. #2

    Default Re: Javascript in web user control

    Here is the HTML source for what I am trying.
    When it creates the controls from the user control it
    puts Test1:TextBox4 as the id. Is there a way to stop
    this or what is the best way to grab that ID?

    <script>function doadd()
    {document.all.TextBox3.value= eval
    (document.all.TextBox1.value) + eval
    (document.all.TextBox2.value)}</script>

    <script>function doadd2()
    {document.all.TextBox6.value= eval
    (document.all.TextBox4.value) + eval
    (document.all.TextBox5.value)}</script>


    <table>
    <tr>
    <td><p>

    <input name="TextBox1" type="text" value="7"
    id="TextBox1" /></p>
    <p>

    <input name="TextBox2" type="text" value="5"
    id="TextBox2" /></p>
    <p>

    <input name="TextBox3" type="text" value="12"
    id="TextBox3" /></p>
    <p>

    <input type="submit" name="Button1" value="Add"
    id="Button1" onclick="doadd();return false;" /></p>
    </td>
    <td>
    <P>
    <input name="Test1:TextBox4" type="text"
    value="7" id="Test1_TextBox4" /></P>
    <P>
    <input name="Test1:TextBox5" type="text"
    value="7" id="Test1_TextBox5" /></P>
    <P>
    <input name="Test1:TextBox6" type="text"
    id="Test1_TextBox6" /></P>
    <P>
    <input type="submit" name="Test1:Button2"
    value="Add" id="Test1_Button2" onclick="doadd2();return
    false;" /></P>
    </td>
    </tr>
    </table>
    >-----Original Message-----
    >Actually correction, ClientID is the property you want.
    >
    >Todd Thompson
    >.
    >
    Christopher Young 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