Hi Peter,
From your description, you use the autoComplete extender to accept input,
and want to make some other textboxes(or fields) on the page get
populated(with some data generated at server-side) without postback,
correct?
According to this scenario, I'm thinking about the updatepanel since it's
the only AJAX control that can help make multiple controls(inside it) do
postback without refreshing page. Also, for your scenario, you may want to
invoke the non-refresh postback based on the Extender's TextBox changed
event.
Based on my research, UpdatePanel support using "AysncPostBackTrigger" to
let you specify an control(outside updatepanel) to cause non-refresh
postback:
#AsyncPostBackTrigger vs PostBackTrigger
http://blog.joelowrance.com/archive/...igger-vs-postb
acktrigger.aspx
#ASP.NET AJAX Extensions Update Panel and Triggers
http://geekswithblogs.net/ranganh/ar...16/112526.aspx
Thus, you can consider add a TextBox's "Textchanged" event as one of the
UpdatePanel's "AsyncPostBackTrigger" so that when textbox changed event
occur(you need to set it to AutoPostBack=True), the updatepanel will help
do async postback, and you can update all the other textboxes in
server-side code.
Here is a test page I've used. I only use a simple Textbox, if you want to
involve AutoComplete Extender, I think you need to customize the extender
since you need to add "TextChanged" event for the textbox:
=========aspx========
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:TextBox ID="txtInput" runat="server" AutoPostBack="True"
ontextchanged="txtInput_TextChanged"></asp:TextBox>
<hr />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click" />
</ContentTemplate>
<Triggers >
<asp:AsyncPostBackTrigger ControlID="txtInput"
EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
==============code behind=============
public partial class UpdatePanelPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
DoWork();
}
void DoWork()
{
TextBox1.Text = DateTime.Now.ToLongTimeString();
}
protected void txtInput_TextChanged(object sender, EventArgs e)
{
DoWork();
}
}
==================================
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Peter" <cz****@nospam.nospam>
Subject: Ajax Postback From JavaScript
Date: Thu, 22 May 2008 21:59:33 -0500
>
ASP.NET
I have an application which use ASP.NET Autocomplete extender which works
great. But I have a question how to update all the fields on the screen
using Ajax.
Users starts typing in a text field which causes the Autocomplete extender
to display 10 like items, after the users selects an item (which is a key
in
>the database) I want the application to go to the database retrieve a
record
>and populate the fields.
I realize I could create JavaScript function that would populate the
fields,
>but I already have the server side code that does that and I don't want to
maintain to different sets of the same code. My question is how to
populate
>the fields on the screen without submitting the entire page to the server
and to have this done after onchange event without requiring user to click
on the Submit button?
I think I have to call C# from JavaScript OnChange event to retreive the
data from the database which I know how to do, but I don't know how to
poputlate the client side textboxes withough using JavaScript or submit
button. So I think I have to use Ajax to do a postback, but how to I do
that from JavaScript.
Thank You
Peter