473,725 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AJAX UpdatePanel PostBack Problem

I have a news section of the website contained within the updatepanel.
What I want is that when a news summary is clicked, the news item
opens up in that same box. I thought I wired everything up correctly
so that it did not do a postback. But when I walked through the
execution process, it in fact does cause a postback when the "expand"
event is raised. Why does this happen? Can someone help me? Thanks.

Here is the .aspx part

1 <%@ Page Language="C#" AutoEventWireup ="true"
CodeFile="Defau lt.aspx.cs" Inherits="_Defa ult" %>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <atlas:ScriptMa nager ID="scriptManag er" runat="server"> </
atlas:ScriptMan ager>
5 <head>
6 <meta name="author" content="Wink Hosting
(www.winkhostin g.com)" />
7 <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
8 <link rel="stylesheet " href="images/style.css" type="text/
css" />
9 <title>Northpoi nt Data Inc.</title>
10 </head>
11 <body>
12 <form id="form1" runat="server">
13 <div id="page" align="center">
14 <div id="content" style="width:80 0px">
15 <div id="logo">
16 </div>
17 <div id="topheader" >
18 <div align="left" class="bodytext ">
19 <br />
20 </div>
21 <div id="toplinks" class="smallgra ytext">
22 <a href="#">Home</a| <a
href="#">Sitema p</a| <a href="#">Contac t Us</a>
23 </div>
24 </div>
25 <div id="menu">
26 <div align="right" class="smallwhi tetext"
style="padding: 9px;">
27 <a href="#">Home</a| <a href="#">About
Us</a| <a href="#">Produc ts</a| <a href="#">Our Services</a| <a
href="#">Contac t Us</a>
28 </div>
29 </div>
30
31 <div id="contenttext ">
32 <div style="padding: 10px">
33 <span class="titletex t">Welcome to
Northpoint Data!</span>
34 </div>
35 <div class="bodytext " style="padding:
12px;" align="justify" >
36 <strong>Hi! This is my third design for
OSWD, with CSS and XHTML 1.0 Transitional Validation. You can do
whatever you want with this template, just keep the Hosting Colombia
link at the bottom. Enjoy! </strong><br />
37 <br />
38 Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Curabitur id est tincidunt nisl pellentesque
tincidunt. Donec in mauris. Mauris neque magna, consectetuer id,
malesuada vitae, tincidunt sit amet, mi. Aliquam lacinia.
Suspendisse potenti. Proin justo lorem, rutrum ac, facilisis in,
malesuada sed, ligula. Mauris lobortis lacus at nibh. Aenean vitae
odio vel odio placerat hendrerit. Suspendisse lacus lacus, tempor
id, pharetra eget, ornare sit amet, pede. Sed aliquet, justo ac
elementum pretium, arcu leo placerat est, a luctus purus diam eget
arcu. Nam augue diam, mollis a, scelerisque eget, aliquet
condimentum, pede. Vestibulum tristique lectus sed augue.<br /><br />
39 Aenean ut mauris luctus mauris interdum
convallis. Nunc vestibulum sodales nulla. Nulla vitae massa. Maecenas
vel tellus vitae elit mattis adipiscing. In pulvinar felis sed est.
Mauris non mi. Duis ultrices dolor ut orci. Quisque lacinia arcu et
purus. Sed euismod metus nec augue. Cum sociis natoque penatibus et
magnis dis parturient montes, nascetur ridiculus mus. Nunc dolor leo,
aliquam a, placerat sit amet, accumsan eget, dolor. Sed lacinia augue
in magna. Fusce sed enim. Vestibulum et mauris. Phasellus in lectus.
Pellentesque eu elit in dolor ullamcorper sodales. Vestibulum interdum
ornare ligula. Mauris felis odio, rhoncus sed, adipiscing fermentum,
tincidunt eu, metus. Suspendisse viverra rhoncus purus.
40 </div>
41 </div>
42 <atlas:UpdatePa nel ID="newsUP" runat="server"
Mode="Condition al">
43 <ContentTemplat e>
44
45 <div id="leftpanel" >
46 <div align="justify"
class="graypane l">
47
48 <asp:Label ID="newz"
runat="server" Visible="false" CssClass="bodyt ext"></asp:Label>
49 <asp:Panel
ID="defaultPane l" runat="server">
50 <span
class="smalltit le">News</span><br /><br />
51 <span
class="smallred text">September 27, 2006</span><br />
52 <span
class="bodytext ">Curabitur arcu tellus, suscipit in, aliquam eget,
ultricies id, sapien. Nam est.</span><br />
53 <asp:LinkButt on
ID="news1" runat="server" CssClass="small graytext" OnCommand="expa nd"
CommandArgument ="1" Text="More..."> </asp:LinkButton> <br /><br />
54 <span
class="smallred text">September 27, 2006</span><br />
55 <span
class="bodytext ">Curabitur arcu tellus, suscipit in, aliquam eget,
ultricies id, sapien. Nam est.</span><br />
56 <asp:LinkButt on
ID="news2" runat="server" CssClass="small graytext" OnCommand="expa nd"
CommandArgument ="2" Text="More..."> </asp:LinkButton> <br /><br />
57 <span
class="smallred text">September 27, 2006</span><br />
58 <span
class="bodytext ">Curabitur arcu tellus, suscipit in, aliquam eget,
ultricies id, sapien. Nam est.</span><br />
59 <asp:LinkButt on
ID="news3" runat="server" CssClass="small graytext" OnCommand="expa nd"
CommandArgument ="3" Text="More..."> </asp:LinkButton> <br /><br />
60 </asp:Panel>
61 <asp:PlaceHolde r
ID="newsP" runat="server">
62 <br />
63 <asp:LinkButt on
ID="back" runat="server" CommandArgument ="back"
CssClass="small graytext" OnCommand="expa nd" Text="back"
Visible="true"> </asp:LinkButton>
64 </asp:PlaceHolder >
65 </div>
66 </div>
67
68 </ContentTemplate >
69 <Triggers>
70 <atlas:ControlE ventTrigger
ControlID="news 1" EventName="Comm and" />
71 <atlas:ControlE ventTrigger
ControlID="back " EventName="Comm and" />
72 </Triggers>
73 </atlas:UpdatePan el>
74 <div id="footer" class="smallgra ytext">
75 <a href="#">Home</a| <a href="#">About Us</
a| <a href="#">Produc ts</a| <a href="#">Our Services</a| <a
href="#">Contac t Us</a>
76 | Northpoint Data Inc.
77 © 2007 | <a href="http://www.winkhosting .com"
target="_blank" >Hosting Colombia</a>
78 </div>
79 </div>
80 </div>
81 </form>
82 </body>
83 </html>

Here is the .cs portion

1 using System;
2 using System.Data;
3 using System.Configur ation;
4 using System.Web;
5 using System.Web.Secu rity;
6 using System.Web.UI;
7 using System.Web.UI.W ebControls;
8 using System.Web.UI.W ebControls.WebP arts;
9 using System.Web.UI.H tmlControls;
10
11 public partial class _Default : System.Web.UI.P age
12 {
13 string test = "Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Curabitur id est tincidunt nisl pellentesque
tincidunt. Donec in mauris. Mauris neque magna, consectetuer id,
malesuada vitae, tincidunt sit amet, mi. Aliquam lacinia.
Suspendisse potenti. Proin justo lorem, rutrum ac, facilisis in,
malesuada sed, ligula. Mauris lobortis lacus at nibh. Aenean vitae
odio vel odio placerat hendrerit. Suspendisse lacus lacus, tempor
id, pharetra eget, ornare sit amet, pede. Sed aliquet, justo ac
elementum pretium, arcu leo placerat est, a luctus purus diam eget
arcu. Nam augue diam, mollis a, scelerisque eget, aliquet
condimentum, pede. Vestibulum tristique lectus sed augue.";
14 protected void Page_Load(objec t sender, EventArgs e)
15 {
16 }
17
18 protected void expand(object sender, CommandEventArg s e)
19 {
20 if (e.CommandArgum ent == "1")
21 {
22 newz.Text = test;
23 newz.Visible = true;
24 newsP.Visible = true;
25 defaultPanel.Vi sible = false;
26 }
27 if (e.CommandArgum ent == "back")
28 {
29 newz.Visible = false;
30 defaultPanel.Vi sible = true;
31 newsP.Visible = false;
32 }
33
34 }
35 }

Mar 7 '07 #1
1 2187
the update panel works as follows:

client script

1) read all controls on page a build a standard post name/value pair string
2) send the post data to page via an iframe or XMLHttpRequest

server code
1) do standard page process
2) fire panel event
3) collect the update panel render html only
4) send the html back to the client script

client script
1) receive postback html
2) replace panels innerHTML with postback html
-- bruce (sqlwork.com)

jobo wrote:
I have a news section of the website contained within the updatepanel.
What I want is that when a news summary is clicked, the news item
opens up in that same box. I thought I wired everything up correctly
so that it did not do a postback. But when I walked through the
execution process, it in fact does cause a postback when the "expand"
event is raised. Why does this happen? Can someone help me? Thanks.

Here is the .aspx part

1 <%@ Page Language="C#" AutoEventWireup ="true"
CodeFile="Defau lt.aspx.cs" Inherits="_Defa ult" %>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <atlas:ScriptMa nager ID="scriptManag er" runat="server"> </
atlas:ScriptMan ager>
5 <head>
6 <meta name="author" content="Wink Hosting
(www.winkhostin g.com)" />
7 <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
8 <link rel="stylesheet " href="images/style.css" type="text/
css" />
9 <title>Northpoi nt Data Inc.</title>
10 </head>
11 <body>
12 <form id="form1" runat="server">
13 <div id="page" align="center">
14 <div id="content" style="width:80 0px">
15 <div id="logo">
16 </div>
17 <div id="topheader" >
18 <div align="left" class="bodytext ">
19 <br />
20 </div>
21 <div id="toplinks" class="smallgra ytext">
22 <a href="#">Home</a| <a
href="#">Sitema p</a| <a href="#">Contac t Us</a>
23 </div>
24 </div>
25 <div id="menu">
26 <div align="right" class="smallwhi tetext"
style="padding: 9px;">
27 <a href="#">Home</a| <a href="#">About
Us</a| <a href="#">Produc ts</a| <a href="#">Our Services</a| <a
href="#">Contac t Us</a>
28 </div>
29 </div>
30
31 <div id="contenttext ">
32 <div style="padding: 10px">
33 <span class="titletex t">Welcome to
Northpoint Data!</span>
34 </div>
35 <div class="bodytext " style="padding:
12px;" align="justify" >
36 <strong>Hi! This is my third design for
OSWD, with CSS and XHTML 1.0 Transitional Validation. You can do
whatever you want with this template, just keep the Hosting Colombia
link at the bottom. Enjoy! </strong><br />
37 <br />
38 Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Curabitur id est tincidunt nisl pellentesque
tincidunt. Donec in mauris. Mauris neque magna, consectetuer id,
malesuada vitae, tincidunt sit amet, mi. Aliquam lacinia.
Suspendisse potenti. Proin justo lorem, rutrum ac, facilisis in,
malesuada sed, ligula. Mauris lobortis lacus at nibh. Aenean vitae
odio vel odio placerat hendrerit. Suspendisse lacus lacus, tempor
id, pharetra eget, ornare sit amet, pede. Sed aliquet, justo ac
elementum pretium, arcu leo placerat est, a luctus purus diam eget
arcu. Nam augue diam, mollis a, scelerisque eget, aliquet
condimentum, pede. Vestibulum tristique lectus sed augue.<br /><br />
39 Aenean ut mauris luctus mauris interdum
convallis. Nunc vestibulum sodales nulla. Nulla vitae massa. Maecenas
vel tellus vitae elit mattis adipiscing. In pulvinar felis sed est.
Mauris non mi. Duis ultrices dolor ut orci. Quisque lacinia arcu et
purus. Sed euismod metus nec augue. Cum sociis natoque penatibus et
magnis dis parturient montes, nascetur ridiculus mus. Nunc dolor leo,
aliquam a, placerat sit amet, accumsan eget, dolor. Sed lacinia augue
in magna. Fusce sed enim. Vestibulum et mauris. Phasellus in lectus.
Pellentesque eu elit in dolor ullamcorper sodales. Vestibulum interdum
ornare ligula. Mauris felis odio, rhoncus sed, adipiscing fermentum,
tincidunt eu, metus. Suspendisse viverra rhoncus purus.
40 </div>
41 </div>
42 <atlas:UpdatePa nel ID="newsUP" runat="server"
Mode="Condition al">
43 <ContentTemplat e>
44
45 <div id="leftpanel" >
46 <div align="justify"
class="graypane l">
47
48 <asp:Label ID="newz"
runat="server" Visible="false" CssClass="bodyt ext"></asp:Label>
49 <asp:Panel
ID="defaultPane l" runat="server">
50 <span
class="smalltit le">News</span><br /><br />
51 <span
class="smallred text">September 27, 2006</span><br />
52 <span
class="bodytext ">Curabitur arcu tellus, suscipit in, aliquam eget,
ultricies id, sapien. Nam est.</span><br />
53 <asp:LinkButt on
ID="news1" runat="server" CssClass="small graytext" OnCommand="expa nd"
CommandArgument ="1" Text="More..."> </asp:LinkButton> <br /><br />
54 <span
class="smallred text">September 27, 2006</span><br />
55 <span
class="bodytext ">Curabitur arcu tellus, suscipit in, aliquam eget,
ultricies id, sapien. Nam est.</span><br />
56 <asp:LinkButt on
ID="news2" runat="server" CssClass="small graytext" OnCommand="expa nd"
CommandArgument ="2" Text="More..."> </asp:LinkButton> <br /><br />
57 <span
class="smallred text">September 27, 2006</span><br />
58 <span
class="bodytext ">Curabitur arcu tellus, suscipit in, aliquam eget,
ultricies id, sapien. Nam est.</span><br />
59 <asp:LinkButt on
ID="news3" runat="server" CssClass="small graytext" OnCommand="expa nd"
CommandArgument ="3" Text="More..."> </asp:LinkButton> <br /><br />
60 </asp:Panel>
61 <asp:PlaceHolde r
ID="newsP" runat="server">
62 <br />
63 <asp:LinkButt on
ID="back" runat="server" CommandArgument ="back"
CssClass="small graytext" OnCommand="expa nd" Text="back"
Visible="true"> </asp:LinkButton>
64 </asp:PlaceHolder >
65 </div>
66 </div>
67
68 </ContentTemplate >
69 <Triggers>
70 <atlas:ControlE ventTrigger
ControlID="news 1" EventName="Comm and" />
71 <atlas:ControlE ventTrigger
ControlID="back " EventName="Comm and" />
72 </Triggers>
73 </atlas:UpdatePan el>
74 <div id="footer" class="smallgra ytext">
75 <a href="#">Home</a| <a href="#">About Us</
a| <a href="#">Produc ts</a| <a href="#">Our Services</a| <a
href="#">Contac t Us</a>
76 | Northpoint Data Inc.
77 © 2007 | <a href="http://www.winkhosting .com"
target="_blank" >Hosting Colombia</a>
78 </div>
79 </div>
80 </div>
81 </form>
82 </body>
83 </html>

Here is the .cs portion

1 using System;
2 using System.Data;
3 using System.Configur ation;
4 using System.Web;
5 using System.Web.Secu rity;
6 using System.Web.UI;
7 using System.Web.UI.W ebControls;
8 using System.Web.UI.W ebControls.WebP arts;
9 using System.Web.UI.H tmlControls;
10
11 public partial class _Default : System.Web.UI.P age
12 {
13 string test = "Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Curabitur id est tincidunt nisl pellentesque
tincidunt. Donec in mauris. Mauris neque magna, consectetuer id,
malesuada vitae, tincidunt sit amet, mi. Aliquam lacinia.
Suspendisse potenti. Proin justo lorem, rutrum ac, facilisis in,
malesuada sed, ligula. Mauris lobortis lacus at nibh. Aenean vitae
odio vel odio placerat hendrerit. Suspendisse lacus lacus, tempor
id, pharetra eget, ornare sit amet, pede. Sed aliquet, justo ac
elementum pretium, arcu leo placerat est, a luctus purus diam eget
arcu. Nam augue diam, mollis a, scelerisque eget, aliquet
condimentum, pede. Vestibulum tristique lectus sed augue.";
14 protected void Page_Load(objec t sender, EventArgs e)
15 {
16 }
17
18 protected void expand(object sender, CommandEventArg s e)
19 {
20 if (e.CommandArgum ent == "1")
21 {
22 newz.Text = test;
23 newz.Visible = true;
24 newsP.Visible = true;
25 defaultPanel.Vi sible = false;
26 }
27 if (e.CommandArgum ent == "back")
28 {
29 newz.Visible = false;
30 defaultPanel.Vi sible = true;
31 newsP.Visible = false;
32 }
33
34 }
35 }
Mar 7 '07 #2

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

Similar topics

2
2813
by: brett | last post by:
I have an AJAX updatepanel in an aspx page. Inside the updatepanel is a placeholder control, which loads various ascx files. This all works fine. One of the ascx files also has an updatepanel in it. In the updatepanel is an ASP.NET image button that does a postback. So, it looks like this: aspx.updatepanel.Add(LoadControl(ascx control)) --ascx.updatepanel --imagebutton
8
2582
by: =?Utf-8?B?SmFrb2IgTGl0aG5lcg==?= | last post by:
I am new to AJAX. I am applying AJAX to a current web solution to get the "instant behaviour". On my main page I have two sets of criteria: Specific and Wide. Each set is placed in a View container. I am not sure that I configured the Triggers correct, but the behaviour is OK. When I click the linkbuttons they switch between two sets of search controls. When I click the search buttons they reload the display panel. BUT .... if the...
6
4020
by: HockeyFan | last post by:
I'd like to have an AJAX textbox that after the user fills in, will auto-fill another textbox on the page without having a postback occur. It doesn't have to do any filtering or any other thing like that. I'm fairly experienced with ASP.Net, but new to AJAX. Please help if you can. Thanx.
7
1729
by: MikeB | last post by:
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?...
1
8201
by: abellix | last post by:
An updatepanel contains a datagrid, this datagrid has columns generated by code-behind: some columns should have async postback, others should have sync postback. Here a sample to reproduce the behaviour: it's a webform with some VB code-behind, you shoud create a new AJAX-enabled application and past the following code. (DEFAULT.ASPX) <%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %> <html...
4
5358
by: Peter | last post by:
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.
1
2053
by: Mark B | last post by:
This is my first try at using AJAX. I want the calendars to be enabled if the user checks CheckBox1. It works OK for a normal all page refresh but once I introduced the AJAX code it stopped working. Any ideas? <%@ Page Language="VB" AutoEventWireup="false" CodeFile="default-ajax.aspx.vb" Inherits="pages_verify_groups_Default" Debug="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
6
2637
by: SAL | last post by:
hello, I'm using a radiobuttonlist in an updatepanel in an item template in a Gridview control. I'm populating the radiobuttonlist in the RowDataBound event. I have the control toolkit registered in the page and I've got code to get the selected value from it in the Radiobuttonlist_SelectedIndexChanged event. The code in there is: Protected Sub rblFMSValue_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
3
3831
by: =?Utf-8?B?Y21lZWsxXzE5OTk=?= | last post by:
Hello, On a webpage, create an UpdatePanel with two DropDownLists. Set AutoPostBack of DropDownList1 to true. In the SelectedIndexChanged method, refill DropDownList2 and set the focus to DropDownList1 using the ScriptManager SetFocus method. Use the Visual Studio debugger. Set a breakpoint on in the (!IsPostBack) part of the PageLoad method. Start the web application and continue after the breakpoint has been reached.
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.