How can bind my dropdown inside ajaxPro method?
-
I am using asp.net 2.0 and ajaxPro in my web application. 1. How can bind my dropdown inside ajaxPro method, without using HtmlTextWriter? Is it possible? All the server controls are null inside the ajaxPro method. 2. So, i have created dynamic server controls inside the ajaxPro method and used HtmlTextWriter and rendered in javascript. Here in javascript, i can't able to get this dynamic controls by using getElementId method. document.getElementId(asp.net control id + "ControlId"); but it returns null. thanx in advance! :)
Thanks & Regards, Jeneesh K. Velayudhan
-
I am using asp.net 2.0 and ajaxPro in my web application. 1. How can bind my dropdown inside ajaxPro method, without using HtmlTextWriter? Is it possible? All the server controls are null inside the ajaxPro method. 2. So, i have created dynamic server controls inside the ajaxPro method and used HtmlTextWriter and rendered in javascript. Here in javascript, i can't able to get this dynamic controls by using getElementId method. document.getElementId(asp.net control id + "ControlId"); but it returns null. thanx in advance! :)
Thanks & Regards, Jeneesh K. Velayudhan
jeneesh k. wrote:
How can bind my dropdown inside ajaxPro method
You can't, databinding is done during page rendering by the ASP.NET engine.
jeneesh k. wrote:
All the server controls are null inside the ajaxPro method.
Of course they are. You need to understand the page lifecycle and ajax calls. Basically, you seem to have no clue about what Ajax is and how to use it. Please do us all, including yourself, a favor and research and understand the technology before trying to use it.
I know the language. I've read a book. - _Madmatt
-
I am using asp.net 2.0 and ajaxPro in my web application. 1. How can bind my dropdown inside ajaxPro method, without using HtmlTextWriter? Is it possible? All the server controls are null inside the ajaxPro method. 2. So, i have created dynamic server controls inside the ajaxPro method and used HtmlTextWriter and rendered in javascript. Here in javascript, i can't able to get this dynamic controls by using getElementId method. document.getElementId(asp.net control id + "ControlId"); but it returns null. thanx in advance! :)
Thanks & Regards, Jeneesh K. Velayudhan
I would recommend moving to ASP.NET AJAX which is built into Visual Studio 2008 and available as additional feature pack for Visual Studio .NET 2005. It provdes an update panel which can bind your controls during an ajax call, here is a simple example ...
<%@ Page Language="C#" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
DropDownList1.Items.Clear();
String[] ds = {"hi","sup"};
DropDownList1.DataSource = ds;
DropDownList1.DataBind();
}</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<style type="text/css">
#UpdatePanel1 {
width:300px; height:100px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="padding-top: 10px">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
<br />
</div></div> </form>
</body>
</html> -
I would recommend moving to ASP.NET AJAX which is built into Visual Studio 2008 and available as additional feature pack for Visual Studio .NET 2005. It provdes an update panel which can bind your controls during an ajax call, here is a simple example ...
<%@ Page Language="C#" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
DropDownList1.Items.Clear();
String[] ds = {"hi","sup"};
DropDownList1.DataSource = ds;
DropDownList1.DataBind();
}</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<style type="text/css">
#UpdatePanel1 {
width:300px; height:100px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="padding-top: 10px">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
<br />
</div></div> </form>
</body>
</html>Hi, i know update panel. I have to make server calls from client side by taking the value from first combo need to populate the second one. dont use selected change event. How it is possible????
Thanks & Regards, Jeneesh K. Velayudhan
-
jeneesh k. wrote:
How can bind my dropdown inside ajaxPro method
You can't, databinding is done during page rendering by the ASP.NET engine.
jeneesh k. wrote:
All the server controls are null inside the ajaxPro method.
Of course they are. You need to understand the page lifecycle and ajax calls. Basically, you seem to have no clue about what Ajax is and how to use it. Please do us all, including yourself, a favor and research and understand the technology before trying to use it.
I know the language. I've read a book. - _Madmatt
Hi, I have to make server calls from client side by taking the value from first combo need to populate the second one. dont use selected change event. How it is possible????
Thanks & Regards, Jeneesh K. Velayudhan
-
Hi, i know update panel. I have to make server calls from client side by taking the value from first combo need to populate the second one. dont use selected change event. How it is possible????
Thanks & Regards, Jeneesh K. Velayudhan
<%@ Page Language="C#" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
DropDownList1.Items.Clear();
String[] ds = {"hi RED","sup RED"};
String[] ds1 = { "hi BLUE", "sup BLUE" };
if (DropDownList2.SelectedValue == "RED")
{
DropDownList1.DataSource = ds;
DropDownList1.DataBind();
}
if (DropDownList2.SelectedValue == "BLUE")
{
DropDownList1.DataSource = ds1;
DropDownList1.DataBind();
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<style type="text/css">
#UpdatePanel1 { width:300px; height:100px; } </style>
</head>
<body>
<form id="form1" runat="server">
<div style="padding-top: 10px">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
asp:ListItemRED</asp:ListItem>
asp:ListItemBLUE</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
<br />
</div>
</div>
</form>
</body>
</html>