Rajesh Kamalakshan
Tuesday, May 4, 2010
How to get the selected text of a microsoft ajax combobox using javascript ?
The belwo example whill show you how to get the selected text of a ajax combobox.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %> <%@ Register assembly="System.Web.Ajax" namespace="System.Web.UI" tagprefix="asp" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Untitled Page</title> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { TextBox textBox = ComboBox1.FindControl("TextBox") as TextBox; if (textBox != null) { textBox.Attributes.Add("onBlur", "cmb_OnBlur(this);"); } } </script> <script language="javascript" type="text/javascript"> function cmb_OnBlur(Text) { alert(Text.value ) } </script> </head> <body> <form id="form1" runat="server"> <asp:AjaxScriptManager ID="AjaxScriptManager1" runat="server"> </asp:AjaxScriptManager> <div> </div> <asp:ComboBox ID="ComboBox1" runat="server"> <asp:ListItem Value="R">Rajesh</asp:ListItem> <asp:ListItem Value="V">Vrinda</asp:ListItem> </asp:ComboBox> </form> </body> </html>
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment