Best way of using Ajax in asp.net

Posted by Ashish.shrma under ASP.NET AJAX on 4/20/2010 | Views : 2154 | Status : [Member] | Replies : 1
What is the best of using ajax in asp.net to devlop a web application.
1) Is it good to have indiual updatepanel for each control in any webpage or webform.
2) When i place an update panel in a new webpage to hold any control. Then in the code part any other control say textSample which is not in update panel does't returns any value. Can any one tell me why this happens.
e.g txtid is in update panel and textSample is not in update panel
if i write this code on button click
dim query as string
query="insert into X(id,sample) values(" & txtid.text & ",'" & txtsample.text & "')
then it does't show any value of txtsample
why is that happening ???
Help Me Out

Ashish


Responses

Posted by: Vuyiswamb on: 4/20/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
1) Is it good to have individual updatepanel for each control in any webpage or webform.

No that means if i have 10 Controls you will have 10 update Panels. Update update Panel must only be used where a Partial Update is needed. if it is abused the page can be very slow to perform its operations.

2) When i place an update panel in a new web page to hold any control. Then in the code part any other control say textSample which is not in update panel doesn't returns any value. Can any one tell me why this happens.

This should work unless you are not giving us the correct info here. i have compiled an example , and its working, please look at it and compare it with yours


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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 runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtid" runat="server"></asp:TextBox>
<br />
<br />
</ContentTemplate>
</asp:UpdatePanel>

</div>
<p>
<asp:TextBox ID="txtsample" runat="server"></asp:TextBox>
</p>
<p>
<asp:Button ID="Button1" runat="server"
onclick="Button1_Click" Text="Button" />
</p>
</form>
</body>
</html>



and Cs like this

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
String Results = txtid.Text + "" + txtsample.Text;

Response.Write(Results);
}
}


Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Ashish.shrma, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response