473,395 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Basic Ajax Help

Hello All, I am new to ajax and wanted to start by trying something simple.
I have a web form with an updatepanel and then inside the update panel I
have a listbox. Then outside of the updatepanel I have a button. In my
buttons click event in the cs / code behind, I have a loop that just inserts
items in the listbox. My question is, once I click the button and the loop
begins, how do I get it to update the listbox? Does this make since?
Basically, this kind of mimics a update page I plan on doing next.
TIA
Oct 10 '07 #1
7 1703
You don't have to do anything it updates by itself. hence the updatepanel.
"MikeB" <m@nospam.comwrote in message
news:OX*************@TK2MSFTNGP06.phx.gbl...
Hello All, I am new to ajax and wanted to start by trying something
simple. I have a web form with an updatepanel and then inside the update
panel I have a listbox. Then outside of the updatepanel I have a button.
In my buttons click event in the cs / code behind, I have a loop that just
inserts items in the listbox. My question is, once I click the button and
the loop begins, how do I get it to update the listbox? Does this make
since? Basically, this kind of mimics a update page I plan on doing next.
TIA

Oct 10 '07 #2
That is what I though however, it is not updating. I must be missing
something. Here is my code behind:

protected void Button1_Click(object sender, EventArgs e)
{

Thread firstThread = new Thread(new ThreadStart(Coundown));
firstThread.Start();
}

public void Coundown()
{
for (int i = 0; i < 100; i++)
{

ListBox1.Items.Add(i.ToString());
Thread.Sleep(250);
}
}

Here is my aspx page:

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ListBox ID="ListBox1" runat="server"
Width="498px"></asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ListBox1"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
</form>
"IfThenElse" <sq**********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
You don't have to do anything it updates by itself. hence the updatepanel.
"MikeB" <m@nospam.comwrote in message
news:OX*************@TK2MSFTNGP06.phx.gbl...
>Hello All, I am new to ajax and wanted to start by trying something
simple. I have a web form with an updatepanel and then inside the update
panel I have a listbox. Then outside of the updatepanel I have a button.
In my buttons click event in the cs / code behind, I have a loop that
just inserts items in the listbox. My question is, once I click the
button and the loop begins, how do I get it to update the listbox? Does
this make since? Basically, this kind of mimics a update page I plan on
doing next.
TIA


Oct 11 '07 #3
This will not update until the end. the browser has to get something back.

"MikeB" <m@nospam.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
That is what I though however, it is not updating. I must be missing
something. Here is my code behind:

protected void Button1_Click(object sender, EventArgs e)
{

Thread firstThread = new Thread(new ThreadStart(Coundown));
firstThread.Start();
}

public void Coundown()
{
for (int i = 0; i < 100; i++)
{

ListBox1.Items.Add(i.ToString());
Thread.Sleep(250);
}
}

Here is my aspx page:

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ListBox ID="ListBox1" runat="server"
Width="498px"></asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ListBox1"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
</form>
"IfThenElse" <sq**********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>You don't have to do anything it updates by itself. hence the
updatepanel.
"MikeB" <m@nospam.comwrote in message
news:OX*************@TK2MSFTNGP06.phx.gbl...
>>Hello All, I am new to ajax and wanted to start by trying something
simple. I have a web form with an updatepanel and then inside the update
panel I have a listbox. Then outside of the updatepanel I have a
button. In my buttons click event in the cs / code behind, I have a loop
that just inserts items in the listbox. My question is, once I click
the button and the loop begins, how do I get it to update the listbox?
Does this make since? Basically, this kind of mimics a update page I
plan on doing next.
TIA



Oct 11 '07 #4
Using AJAX, am I able to update the listbox as it is updated?

"IfThenElse" <sq**********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
This will not update until the end. the browser has to get something
back.

"MikeB" <m@nospam.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>That is what I though however, it is not updating. I must be missing
something. Here is my code behind:

protected void Button1_Click(object sender, EventArgs e)
{

Thread firstThread = new Thread(new ThreadStart(Coundown));
firstThread.Start();
}

public void Coundown()
{
for (int i = 0; i < 100; i++)
{

ListBox1.Items.Add(i.ToString());
Thread.Sleep(250);
}
}

Here is my aspx page:

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ListBox ID="ListBox1" runat="server"
Width="498px"></asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ListBox1"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
</form>
"IfThenElse" <sq**********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>You don't have to do anything it updates by itself. hence the
updatepanel.
"MikeB" <m@nospam.comwrote in message
news:OX*************@TK2MSFTNGP06.phx.gbl...
Hello All, I am new to ajax and wanted to start by trying something
simple. I have a web form with an updatepanel and then inside the
update panel I have a listbox. Then outside of the updatepanel I have
a button. In my buttons click event in the cs / code behind, I have a
loop that just inserts items in the listbox. My question is, once I
click the button and the loop begins, how do I get it to update the
listbox? Does this make since? Basically, this kind of mimics a update
page I plan on doing next.
TIA



Oct 11 '07 #5
Your thread does not end to send anything back??
"MikeB" <m@nospam.comwrote in message
news:eU**************@TK2MSFTNGP06.phx.gbl...
Using AJAX, am I able to update the listbox as it is updated?

"IfThenElse" <sq**********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>This will not update until the end. the browser has to get something
back.

"MikeB" <m@nospam.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>That is what I though however, it is not updating. I must be missing
something. Here is my code behind:

protected void Button1_Click(object sender, EventArgs e)
{

Thread firstThread = new Thread(new ThreadStart(Coundown));
firstThread.Start();
}

public void Coundown()
{
for (int i = 0; i < 100; i++)
{

ListBox1.Items.Add(i.ToString());
Thread.Sleep(250);
}
}

Here is my aspx page:

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ListBox ID="ListBox1" runat="server"
Width="498px"></asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ListBox1"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
</form>
"IfThenElse" <sq**********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl.. .
You don't have to do anything it updates by itself. hence the
updatepanel.
"MikeB" <m@nospam.comwrote in message
news:OX*************@TK2MSFTNGP06.phx.gbl...
Hello All, I am new to ajax and wanted to start by trying something
simple. I have a web form with an updatepanel and then inside the
update panel I have a listbox. Then outside of the updatepanel I have
a button. In my buttons click event in the cs / code behind, I have a
loop that just inserts items in the listbox. My question is, once I
click the button and the loop begins, how do I get it to update the
listbox? Does this make since? Basically, this kind of mimics a update
page I plan on doing next.
>
>
TIA
>




Oct 11 '07 #6
you're missing the basic concept of browsers and ajax. ajax is a pattern
used in javascript to make a web service call (via xmlhttprequest), and
then process the reponse, usually with some dynamic html.

the updatepanel when triggered:

1. javascript sends a request to page with all form fields via
xmlhttprequest
2. the server processes the form data like a normal postback
3. the server runs a special render that only renders the updatepanel(s)
4. the server sends updatepanel html back the client
5. a javascript async event is fired by xmlhttprequest when the html is
returned
6. javascript event handler replaces the contents of the updatepanel
with the html
so nothing happens in the update anel until the html is sent back.
-- bruce (sqlwork.com)
MikeB wrote:
Using AJAX, am I able to update the listbox as it is updated?

"IfThenElse" <sq**********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>This will not update until the end. the browser has to get something
back.

"MikeB" <m@nospam.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>That is what I though however, it is not updating. I must be missing
something. Here is my code behind:

protected void Button1_Click(object sender, EventArgs e)
{

Thread firstThread = new Thread(new ThreadStart(Coundown));
firstThread.Start();
}

public void Coundown()
{
for (int i = 0; i < 100; i++)
{

ListBox1.Items.Add(i.ToString());
Thread.Sleep(250);
}
}

Here is my aspx page:

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ListBox ID="ListBox1" runat="server"
Width="498px"></asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ListBox1"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
</form>
"IfThenElse" <sq**********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl.. .
You don't have to do anything it updates by itself. hence the
updatepanel.
"MikeB" <m@nospam.comwrote in message
news:OX*************@TK2MSFTNGP06.phx.gbl...
Hello All, I am new to ajax and wanted to start by trying something
simple. I have a web form with an updatepanel and then inside the
update panel I have a listbox. Then outside of the updatepanel I have
a button. In my buttons click event in the cs / code behind, I have a
loop that just inserts items in the listbox. My question is, once I
click the button and the loop begins, how do I get it to update the
listbox? Does this make since? Basically, this kind of mimics a update
page I plan on doing next.
>
>
TIA
>


Oct 11 '07 #7
What about adding this to the end of your code:

UpdatePanel1.update();

This will refresh the update panel from outside of the updatepanel to
reflect the changes in the list.

Bjorn

"MikeB" <m@nospam.comwrote in message
news:eU**************@TK2MSFTNGP06.phx.gbl...
Using AJAX, am I able to update the listbox as it is updated?

"IfThenElse" <sq**********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>This will not update until the end. the browser has to get something
back.

"MikeB" <m@nospam.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>That is what I though however, it is not updating. I must be missing
something. Here is my code behind:

protected void Button1_Click(object sender, EventArgs e)
{

Thread firstThread = new Thread(new ThreadStart(Coundown));
firstThread.Start();
}

public void Coundown()
{
for (int i = 0; i < 100; i++)
{

ListBox1.Items.Add(i.ToString());
Thread.Sleep(250);
}
}

Here is my aspx page:

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ListBox ID="ListBox1" runat="server"
Width="498px"></asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ListBox1"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
</form>
"IfThenElse" <sq**********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl.. .
You don't have to do anything it updates by itself. hence the
updatepanel.
"MikeB" <m@nospam.comwrote in message
news:OX*************@TK2MSFTNGP06.phx.gbl...
Hello All, I am new to ajax and wanted to start by trying something
simple. I have a web form with an updatepanel and then inside the
update panel I have a listbox. Then outside of the updatepanel I have
a button. In my buttons click event in the cs / code behind, I have a
loop that just inserts items in the listbox. My question is, once I
click the button and the loop begins, how do I get it to update the
listbox? Does this make since? Basically, this kind of mimics a update
page I plan on doing next.
>
>
TIA
>




Oct 11 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Yarco | last post by:
I want to use "Ajax" to create my web for hobby. But i don't know whether "Ajax" is mature... And what about with php? Someone have experience on it? ....
4
by: Mason Barge | last post by:
I'm learning how to build a website. So far I've gotten pretty good with HTML, CSS, and Paint Shop Pro, and I'm currenly learning the basics of Javascript. I'm hoping, eventually, to build and...
2
by: tarun.sinha | last post by:
Hello All Please Help me out, I have heard about Ajax Programming. I want to use it in my application but i can't understand the basic of Ajax.I serach a lot and studied in google Please...
11
by: walterbyrd | last post by:
With PHP, libraries, apps, etc. to do basic CRUD are everywhere. Ajax and non-Ajax solutions abound. With Python, finding such library, or apps. seems to be much more difficult to find. I...
7
by: tommurray | last post by:
Hi all Hope someone can help with the problem I am having as it is driving me nuts! I have the below script on my site the problem lies with passing through a url parameter in the below line...
10
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
controlsPlease could some of you here post some of your live examples of AJAX (esp drag panels, collapsable panels, and popup menu.) (It's one thing to talk about how great something is, but it's...
6
by: Jonathan Wood | last post by:
Greetings, I'd like to implement some AJAX features on an existing ASP.NET site. I have one example of doing this but, otherwise, don't know much about it. I have one question, though, about...
2
by: BobF | last post by:
<given> When starting a new AJAX Control enabled site, a set of files are created. These are created -without- a master page. </given> To add a master page, I've been adding the master via...
11
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have run into a situation that if a page/tab that uses the Ajax toolkit (using .net version 3.5) is closed before the Ajax enable controls complete loading, then IE locks up. Does it in both IE7...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.