Click here to Skip to main content
15,921,179 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a dropdown which are having ac,nonac ,delux items in it.iam entering data in a textbox of aspx page 1 after button click its going to next page and adding textbox text to dynamically created button but i want add button based on selection of dropdown.i retrieved buttontext from db using reader evry time it adds button along with text .but i want to make it like below .how should i add based on my selection type.
suppose :
ac : BUTTON123
NONAC : BUTTON233
DELUX : BUTTON234

What I have tried:

  DropDownList1.Items.Add("AC");
            DropDownList1.Items.Add("NON-AC");
            DropDownList1.Items.Add("DELUX");

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text!= "")
            {
                string s = TextBox1.Text;
                Response.Redirect("WebForm2.aspx?val=" + TextBox1.Text);
            }

in aspx2 

  protected void Page_Load(object sender, EventArgs e)
        {
           


            Button b = new Button();
            b.Text =Request.QueryString["val"];
           Panel1.Controls.Add(b);
Posted
Updated 7-Jun-17 2:23am
Comments
Afzaal Ahmad Zeeshan 7-Jun-17 14:19pm    
If that has to be done through client-side, then why not JavaScript?

1 solution

try

protected void Button1_Click(object sender, EventArgs e)
       {
           string value = DropDownList1.SelectedItem.Value;
           Response.Redirect("WebForm2.aspx?val=" + value);

       }
 
Share this answer
 
Comments
Richard Deeming 7-Jun-17 11:26am    
You'll probably want to URL-encode the value:
Response.Redirect("WebForm2.aspx?val=" + HttpUtility.UrlEncode(value));

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900