Introduction :
In this post I will show you how to get the value of a HTML Drop Down List from the code behind (C# code) in ASP.NET. To do this we need a HTML Drop Down List with values and one ASP Button. And on that Button click we will get the selected value from the Code Behind.
Description :
In the previous examples Suresh Dasari had explained AJAX Country State select from Drop Down List, Show toolip in mouse hover of Drop Down List, SQL Databind in ASP Drop Down List, Validate Drop Down List using JQuery. Now here I will explain get the selected HTML Drop Down List value from Code Behind(.CS file).
So, lets start with creating a new project. Named it what ever you want. And then add a new WebForm. In this WebForm for a Drop Down List we usually use the ASP Drop Down List, but today we will use a simple HTML Drop Down List. So take a Drop Down List and fill it up with values.
Now add a new ASP Button and generate the Click event of that Button. Now on the button click event write down the following code for C#.
Run your project and get the value of a HTML Drop Down List selected item from Code Behind (C#). Enjoy... :)
In this post I will show you how to get the value of a HTML Drop Down List from the code behind (C# code) in ASP.NET. To do this we need a HTML Drop Down List with values and one ASP Button. And on that Button click we will get the selected value from the Code Behind.
Description :
In the previous examples Suresh Dasari had explained AJAX Country State select from Drop Down List, Show toolip in mouse hover of Drop Down List, SQL Databind in ASP Drop Down List, Validate Drop Down List using JQuery. Now here I will explain get the selected HTML Drop Down List value from Code Behind(.CS file).
So, lets start with creating a new project. Named it what ever you want. And then add a new WebForm. In this WebForm for a Drop Down List we usually use the ASP Drop Down List, but today we will use a simple HTML Drop Down List. So take a Drop Down List and fill it up with values.
Now add a new ASP Button and generate the Click event of that Button. Now on the button click event write down the following code for C#.
string ddl = ""; // to get the selected value ddl = Request.Form["ddlName"].ToString(); Respose.Write("Name : "+ ddl);
Run your project and get the value of a HTML Drop Down List selected item from Code Behind (C#). Enjoy... :)
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
2 comments :
i got null exception in(ddl = Request.Form["ddlName"].ToString();)
Note: Only a member of this blog may post a comment.