locked
Hello world not printing in Textbox after selecting item in dropdownlist RRS feed

  • Question

  • User-1767837043 posted
    <asp:DropDownList ID="ddlCharge" runat="server" Width="260px" SkinID="260px" TabIndex="9">
    </asp:DropDownList>
    <asp:RequiredFieldValidator ID='rfvCharge' runat='server' InitialValue='0' ControlToValidate='ddlCharge' Text="&nbsp" ErrorMessage='*' Display='Dynamic' SetFocusOnError='True' ValidationGroup='vgCharge'></asp:RequiredFieldValidator> <asp:TextBox ID="txtPostFix" runat="server" TabIndex="10"></asp:TextBox>  

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then Ajax.Utility.RegisterTypeForAjax(GetType(Page_Path))
    ddlCharge.Attributes.Add("onchange", "$('#<%=txtPostFix.ClientID%>').val('hello world')")
    End If
    End Sub

    Saturday, March 23, 2019 5:37 AM

All replies

  • User475983607 posted

    You writing the following to the browser.  Use the browser's dev tools (F12) to view the results.

    $('#<%=txtPostFix.ClientID%>').val('hello world') 

    Change the string to this.

    "$('#" + txtPostFix.ClientID + "').val('hello world')"

    Saturday, March 23, 2019 12:05 PM