Troubleshooting Question
I am trying to populate a TextBox within an ASPX page (C#) with a dropdownlist value using JQuery. I have no idea if this is right. I'm simply trying things I am readying on the internet. The Javascript says that DDL_ID (which I assume would be the dropdowlist) and TextBoxID (which i assume is the textbox) CANT BE FOUND. I don't know if this will work or not but I am trying anything I can at this point to prevent users from having to type in a freeformtextbox.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="echodevelopment.WebForm3" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery-3.5.1.min.js"></script>
<script type="text/javascript">
$('#<%= DDL_ID.ClientID %>').change(function() {
$('#<%= TextBoxID.ClientID %>').val($(this).val());
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>form
</div>
<div>
<asp:FormView ID="FormView1" runat="server" AllowPaging="True" DataKeyNames="id" DataSourceID="SqlDataSource1">
<EditItemTemplate>
id:
<asp:Label ID="idLabel1" runat="server" Text='<%# Eval("id") %>' />
<br />
City:
<asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
<br />
Citycode:
<asp:DropDownList ID="DDL_ID" runat="server" >
<asp:ListItem Value="0" Selected="True">Select</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="TextBoxID" runat="server" Text='<%# Bind("Citycode") %>'/>
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>