how to get dropdown selected value in textbox without using javascript.
Initially textbox must not visible once we select item from dropdown, textbox with selected value must be visible.(asp.net web application)
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Nov 29, 2013, 7:16 PM EST
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
in .cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox1.Visible = true;
TextBox1.Text = DropDownList1.SelectedValue;
}
}
Satyapriya NayakRank #47 · 31.5K reputationPosted Nov 29, 2013, 7:22 PM EST
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace WebApplication8
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TextBox1.Visible = false;
DropDownList1.Items.Add("---select-");
DropDownList1.Items.Add("a");
DropDownList1.Items.Add("b");
DropDownList1.Items.Add("c");
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox1.Visible = true;
TextBox1.Text = DropDownList1.SelectedItem.Text;
}
}
}
samantaRank #3,157 · 454 reputationPosted Nov 29, 2013, 10:40 PM EST