Showing posts with label content. Show all posts
Showing posts with label content. Show all posts

Wednesday, March 28, 2012

UpdateProgress not reacting to LinkButtons in MultiView and FormView

I have a Content Page with two UpdatePanels. The first one has a FormView inside it and second one has MultiView with several Views. In each of this views I have a GridView in it. I change the views by LinkButtons that are also in the same UpdatePanel.

My problem is that none of the PostBack events in the UpdatePanels seem to fire the UpdateProgress. However, if I add a third UpdatePanel with a Label and a Button whith the following code, it does react to the Button click.

ProtectedSub btnTest_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)

System.Threading.Thread.Sleep(3000)

lblTest.Text = DateTime.Now.ToString()

EndSub

But it still won't react to the events in the other two panles. Am I doing something wrong? All help would be greatly appriciated.

Thank you.

One more thing:

I can also move the Label and the Button to one of the exisiting UpdatePanels and the Button Click event does fire the UpdateProgress correcctly.


I also have two DropDownLists in the FromView (located inside a UpdatePanel) with PostBack events. Shouldn't that trigger the UpdateProgess?

Anyone?Tongue Tied

Thank you.


I did some futher testing and noticed if I copy the following in the LinkButton Click Sub, the UpdateProgress shows for that 3 seconds:

System.Threading.Thread.Sleep(3000)

So basically it seems only to work when sleeping but not when doing actually something, like sorting data in the GridView.Huh?

Is there anyway to fire the UpdateProgress manually?


Found an interesting link that almost (but not quite) handels my problem:

http://smarx.com/posts/why-the-updateprogress-wont-display.aspx


I tryed to use UpdatePanelAnimationExtender instead and found out a strage thing. When using the following code clicking the button that does that sleep thing, everything works fine. But when I do any other action on the that UpdatePanel (click a LinkButton that chages the active View, sort data in the GridView) the OnUpdating animation (FadeOut) only begins and then stops for several seconds until the data is rendered and then the OnUpdated animation (FadeIn) runs entirely. Strange!Hmm

<cc1:UpdatePanelAnimationExtenderID="UpdatePanelAnimationExtender1"runat="server"TargetControlID="upnDataTabs">

<Animations>

<OnUpdating>

<FadeOutDuration="1"Fps="40"/>

</OnUpdating>

<OnUpdated>

<FadeInDuration=".5"Fps="20"/>

</OnUpdated>

</Animations>

</cc1:UpdatePanelAnimationExtender>

I seem to be talking to myself here... MUST TAKE MY MEDICAIONIndifferent

UpdateProgress Problem

I'd like to show the update progress template in the center of div, which content is updated with update panel. I tried to do it with z-index.. but it works only with absolute positioning so it can be centered only in the whole browser window. What should i do to make it work in the right way? =)

Here is a simple illustration of the feature i need

*****************Update Panel*************
* *

* *

* Loading... *

* *

* *

**********************************************


I have anarticle on creating a modal UpdateProgress. It uses absolute positioning, but you can use relative positioning to position the message within your container. There is ademo available as well... you can use Firebug to mess around a bit with the styles in real-time (just disable the visible=hidden style on the UpdateProgress' main DIV).

Hope this helps.

-Damien


Everything work nice when we use absolute positioning.. but with realtive positioning z-index doesn't work so i failed to put it to foreground.

According tohttp://msdn2.microsoft.com/en-us/library/ms533005.aspx

It is quite possible that relatively positioned elements will overlap with other objects and elements on the page. As with absolute positioning, you can use the z-index attribute to set thez-index of the positioned element relative to other elements that might occupy the same area. By default, a positioned element always has a higher z-coordinate than its parent element so that it will always be on top of its parent element.

I also messed around with the styles on the sample I sent you using FireBug and verified that I was able to set the z-index on a relative positioned element. For example:

#processMessage {

background-color:#FFFFFF;

border:1px solid #000000;

left:43%;

padding:10px;

position:relative;

top:-300px;

width:14%;

z-index:1001;

}

-Damien


You are looking like this one

http://mattberseth.com/blog/2007/06/aspnet_ajax_canceling_an_async_1.html


Thx! Look like it's what i need =)

Monday, March 26, 2012

Updating ContentPlaceHolder using UpdatePanel(like using frames)

Hi guys,

Is there a way to update the whole Content page without master page refreshing it self? like same effect as using frames or iframes in html.

I tried following, just simply placing script manager and wrapping ContentPlaceHolder with UpdatePanel, which didn't work.

Any suggestions?


<%@dotnet.itags.org. Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>
<html>
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager" runat="server"></asp:ScriptManager>
<div id="main"
<div id="titleBar">Title</div>

<div id="siteMenu">
<asp:Menu ID="Menu1" runat="server" SkinID="MenuBar" DataSourceID="SiteMapDataSource1" OnMenuItemClick="Menu1_MenuItemClick">
</asp:Menu>
</div>


<div id="content">

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate
<asp:contentplaceholder id="contents" runat="server"></asp:contentplaceholder>


</ContentTemplate>
</asp:UpdatePanel>
</div>


<div id="footer">footer</div
</div
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</form>
</body>
</html>



Sorry to say that master pages and AJAX don't work together in that fashion (seehttp://odetocode.com/Blogs/scott/archive/2007/01/03/9682.aspx).

There are lots of ways to refresh the content inside of the page using AJAX, but what you are trying to do requires the browser to load an entirely new page. :/


Thanks Scott.

I won't be wasting any more time trying to figure that one out.

Guess I am back to using good old Iframe.

Cheers

Dosa.

Updating MasterPage panel from content page

Hello,

I have created a shopping cart which users can add products to within an update panel in a content page. However in the masterpage there is a 'basket' that displays how many products are currently in the basket. I need to find a way of updating this basket whenever the updatepanel in the content page is reloaded. Is this possible.

Thanks,

Curt.

Yes, create a Public Property on your Master Page and set the baskek based on this value. The value can then be updated from your content page (you can get access to the Master Page via Page.Master).


Thank you for your reply.

Could you give me some more help on how to do this as I don't have much experience with Public Properties just yet?

Thanks.


Here's a sample Public Property with a type of String:

Public Property Name()As String Get Return _NameEnd Get Set(ByVal valueAs String) _Name = valueEnd Set End Property

updating only portion of a User control

Hi,

I Have an application Where I am dyanmically Loading User controls in a Main Page Content area(in an Update Panel)

And Each user control has its own update panel. for Example I have a List box and a text box and the Text box is in an update panel

And when the user select an item in the list box i need to update the text box upadate panel.

But the problem is since all these controls are in a user control and the user control loads in a place holder in an update panel in my main page.

To get the events of the user control child controls i need to load it again while asynchrounous post back

ie When user selects a menu item i am loading my user control into a place holder in an update panel in the main page.

and when the user clicks on the list box in my user control to get the selected index changed event i need to load the user control again

in my cs code. to the place holder . but i am only updating the text box in my user control. and so i placed that in an update panel.

but the problem is since my user control is inside an update panel in my main page the whole user control get refreshed.

I put the update mode of my main page update panel as conditional and when the user double clicks on the list box i load the user control in the palce holder so that i will get the events but i didn't update the main update panel. I did call only update for the update panel for the text box(which is in my user control)

but still my whole user controls get refeshed . Is there any solution for this

Thanks and regards

jereesh

Where the control that make posteback is located , is it inside your main update panel ?

if yes so you have to set "ChildrenAsTriggers" of your main update panel to false.

please let us know about your aspx code


HiI have a Main page where there is an update panel( where a place holder exists )which is made as conditionalAnd I have user controls(ascx) which are dynamically loaded into this update panel-into the place holder-(when user clicks on different menu items in main page. And inside each user Control there is an update panel where all child controls are placedand I may have update panels for individual controls in user controlfor example in one of my user control I have a list box and a text box and when i double click on the list box i need to change the text box value so i kept the text box inside an update Panel. but the problem is when i click on the list box in a user control if i need to get the event(selected indexchnaged) for that user control i need to load it again to the place holder in the cs file(Main.aspx.cs), ie if may user control name is search.ascxi am usong LoadControl method and adding it to the placeholder in my main page(this should happen each time when any postback occurs because of an event for a child control in the user control- then only i will get its events).I kept all update panel's update mode as conditional. and I will call only update for the update panelwhre my text box exists ( ie the update panel inside my user control). I only call Update for my main update panelonly when I need to load another user control ie when the user selects another menu item from the main page. mainupdatepanel -- Upadated only when new user control is to be loade usercontrolupdatepanel - Updated conditionally usercontrolchildcontrolUpdatepanel-- updates conditionallyThanks and Regards

Hi,

You have to set "ChildrenAsTriggers" of your main update panel to false.

Best Regards,

Saturday, March 24, 2012

updating updatepanel in content page from javascript __doPostBack method.

Hi all,

Please help me on this issue..i have tried/looked every where but no solutions yet...I have two updatepanels, one in master page and another in content page.Then from master page i opening a modal window and after some calculation , i want to refresh/update my updatepanel in the content page.Now i have placed a hidden button inside the content page and made it as a trigger for the updatepanel in content page.I am able to call the click event of the hidden button and execute the code that i have written in the server side.But my problem is that my updatepanel in the content page is not getting updated with the changes..

thanks in advance

Have you tried UpdatePanel.Update() in code behind??


Try it like this:http://encosia.com/index.php/2007/07/13/easily-refresh-an-updatepanel-using-javascript/

Hi,

Actually to refresh my update panel on the parent page from popup widow , i'm using hidden button method.Let me explain it with example:

Here is my master page code

<%@.MasterLanguage="C#"AutoEventWireup="true"CodeFile="Menu.master.cs"Inherits="Menu" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>New Page</title>

<scripttype="text/javascript"language="javascript">

function CallFunction()

{

var obj =new Object();

obj.First = window;

window.showModalDialog('Forms.aspx', obj,'status:no; dialogHeight:155px;dialogWidth:510px; help:no; scroll:no; menubar:no; resizable:no')

}

</script>

</head>

<body>

<formid="form1"runat="server">

<asp:ScriptManagerID="Scriptmanager1"runat="server"></asp:ScriptManager>

<asp:UpdatePanelID="updMaster"UpdateMode="Conditional"runat="server">

<ContentTemplate>

<div>

<tableborder="2"cellpadding="0"style="background-color: #ff3300; width: 345px;" cellspacing="0">

<tr>

<tdalign="center"style="width: 164px; height: 26px;">

<inputtype="button"id="btn"name="btn"onserverclick="btn_Click"value="Click"runat="server"/>

</td>

<tdalign="center"style="height: 26px">

<asp:ButtonID="btnNew"Text='New'BackColor="#FFC080"OnClick="btnNew_Click"BorderColor="#FFC0C0"runat="server"Width="62px"/>

</td>

</tr>

</table>

</div>

<asp:contentplaceholderid="ContentPlaceHolder1"runat="server">

</asp:contentplaceholder>

</ContentTemplate>

</asp:UpdatePanel>

</form>

</body>

</html>

I have two buttons on it.Then onserverclick event of first butto i.e, btn i'm opening a modalwindow. Here is the code for that


protected void btn_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();

sb.Append("<script language='");
sb.Append("JavaScript'>");
sb.Append("\n");
sb.Append("var obj = new Object();");
sb.Append("\n");
sb.Append("obj.First = window;");
sb.Append("\n");
sb.Append("obj.Second = 'Content3.aspx';");
sb.Append("\n");
sb.Append("window.showModalDialog('Forms.aspx', obj, 'status:no; dialogHeight:155px;dialogWidth:510px; help:no; scroll:no; menubar:no; resizable:no');");
sb.Append("\n");
sb.Append("</");
sb.Append("script>");
ScriptManager.RegisterStartupScript(this, this.GetType(), "PopUp", sb.ToString(), false);

}

Then here is my content page code:I've one textbox and one hidden button

<%@.PageLanguage="C#"MasterPageFile="~/Menu.master"AutoEventWireup="true"CodeFile="Content3.aspx.cs"Inherits="Content3"Title="Untitled Page" %>

<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

<scripttype="text/javascript">

function test()

{

var invisibleButton = document.getElementById('<%= btnNo.ClientID %>');

__doPostBack(invisibleButton.name,'');

}

</script>

<asp:ButtonID="btnNo"OnClick="btnNo_Click"runat="server"style="display:none;"/>

<asp:UpdatePanelID="updContent"UpdateMode="Conditional"ChildrenAsTriggers="false"runat="server">

<ContentTemplate>

<tablewidth="340px"border="2"cellpadding="0"cellspacing="0">

<tr>

<td>

<asp:TextBoxid="txt1"runat="server"></asp:TextBox>

<td>

<asp:TextBoxid="txt2"runat="server"></asp:TextBox>

</td>

</tr>

<tr>

<td></td>

</tr>

</table>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTriggerControlID="btnNo"EventName="Click"/>

</Triggers>

</asp:UpdatePanel>

</asp:Content>

Then afterthis from the modal window i'm calling the parent pages javascript function i.e, test();

which i've defined in the content page.And also on the click event of the hidden button i'm basically upadting the text box.Here are the codes for both content page and modal window.

protectedvoid btnNo_Click(object sender,EventArgs e)

{

this.txt2.Text ="From Modal Window";

}

for modal window to call parents page function

var oMyObject;

var firstArg;

var secondArg;

oMyObject = window.dialogArguments;

firstArg = oMyObject.First;

//secondArg = oMyObject.Second;

function PassData()

{

firstArg.test(); //function defined in the content page.

window.close();

}

Now this calling the hidden button click event but the text box thta is in the content page updatepanel it is not getting updated.More ever i've found one more thing i.re if i open the modal window directly from master page i.e using javascript this whole functionality works perfectly and the text box in the content page is getting updated.But i want open the modal window through server side only using ScriptManager.RegisterStartScript method...So is there anything tht i'm doing wrong...

please help me on this issue.....

thanks in advance

sarthaks


Hi,

I'm a little bit confused with your sample, and I wasn't able to show the modal dialog.

Can you post a sample that can fully reproduce your logic?


Hi ,

For my sample application i have created three pages.

1.Menu.Master (master page)

2.Contet.aspx(Content Page in which i have added my master page i.e Menu.Master)

3.Form.aspx(To display it as a modal dialog box.)

Page Design For My master page:

<%@.MasterLanguage="C#"AutoEventWireup="true"CodeFile="Menu.master.cs"Inherits="Menu" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Menu</title>

</head>

<body>

<formid="form1"runat="server">

<asp:ScriptManagerID="Scriptmanager1"runat="server"></asp:ScriptManager>

<asp:UpdatePanelID="updMaster"UpdateMode="Conditional"runat="server">

<ContentTemplate>

<div>

<tableborder="2"cellpadding="0"style="background-color: #ff3300; width: 345px;"cellspacing="0">

<tr>

<tdalign="center"style="width: 164px; height: 26px;">

<inputtype="button"id="btn"name="btn"onserverclick="btn_Click"value="Click"runat="server"/>

</td>

</tr>

</table>

</div>

</ContentTemplate>

</asp:UpdatePanel>

<asp:contentplaceholderid="ContentPlaceHolder1"runat="server"></asp:contentplaceholder>

</form>

</body>

</html>

In my master page i have placed one input button.And on itsonserverclick event i am opening up the modal dialog box i.e, Form.aspx

Here is the server side code for the button

protectedvoid btn_Click(object sender,EventArgs e)

{

StringBuilder sb =newStringBuilder();

sb.Append("<script type='text/javascript' language='");

sb.Append("JavaScript'>");sb.Append("\n");

/************************************************/

sb.Append("var obj = new Object();");

sb.Append("\n");sb.Append("obj.FirstArg = window ;");

/* The above three lines is used to pass the reference of the parent window to the modal window. Using which i can call any javascript function of parent window from my modal dialog window*/

sb.Append("\n");

sb.Append("window.showModalDialog('Forms.aspx',obj, 'status:no; dialogHeight:155px;dialogWidth:510px; help:no; scroll:no; menubar:no; resizable:no');");

sb.Append("\n");

sb.Append("</");sb.Append("script>");

ScriptManager.RegisterStartupScript(btn,Type.GetType("System.String"),"PopUp", sb.ToString(),false);

}

Page Design For for modal dialog window.

<%@.PageLanguage="C#"AutoEventWireup="true"CodeFile="Forms.aspx.cs"Inherits="Pages_Forms" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Forms</title>

<scripttype="text/javascript"language="javascript">

var oMyObject;var firstArg;

oMyObject = window.dialogArguments;

firstArg = oMyObject.FirstArg; /* To retrieve any data from the parent window.*/

function PassData()

{

firstArg.test();

window.close();

}

</script>

</head>

<body>

<formid="form1"runat="server">

<div>

<tablecellpadding="0"cellspacing="0"border='1'>

<tr>

<tdstyle="width:600px;"align='center'>

<tablewidth="500px"cellspacing="2"cellpadding='0'border='0'>

<trstyle="height:10px;">

<tdstyle="width: 126px"> </td>

</tr>

<trstyle="height: 10px">

<tdstyle="text-align: center; width: 721px;">

<spanstyle="font-size: 11pt; color: #ffffff; font-family: Arial">

Do you want to save the changes you have made? </span></td>

</tr>

<trstyle="height: 10px">

<tdstyle="width: 126px; text-align: center"></td>

<tdstyle="width: 721px; text-align: center">

<inputid="btnNo"type="button"value="Yes"name="Yes"style="width:58px;"onclick="PassData();"runat="server"/>

<inputid="btnCancel"type="button"value="Cancel"onclick="window.close();"name="Cancel"runat="server"/>

</td>

</tr>

</table>

</td>

</tr>

</table>

</div>

</form>

</body>

</html>

I have two buttons on my form page Yes and Cancel .Onclick of Yes i am calling a javascript function which is there in my parent page( in this case i have wriitten the function in my content page.Function name is test();).

page design for my content page.

<%@.PageLanguage="C#"MasterPageFile="~/Menu.master"AutoEventWireup="true"CodeFile="Content3.aspx.cs"Inherits="Content3"Title="Untitled Page" %>

<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

<scripttype="text/javascript">

function test()

{

var invisibleButton = document.getElementById('<%= btnNo.ClientID %>');

__doPostBack(invisibleButton.name,'');

}

</script>

<asp:ButtonID="btnNo"OnClick="btnNo_Click"runat="server"style="display:none;"/>

<asp:UpdatePanelID="updContent"UpdateMode="Conditional"ChildrenAsTriggers="false"runat="server">

<ContentTemplate>

<tablewidth="340px"border="2"cellpadding="0"cellspacing="0">

<tr>

<td>

<asp:TextBoxid="txt1"runat="server"></asp:TextBox>

<td>

<asp:TextBoxid="txt2"runat="server"></asp:TextBox>

</td>

</tr>

<tr>

<td></td>

</tr>

</table>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTriggerControlID="btnNo"EventName="Click"/>

</Triggers>

</asp:UpdatePanel>

</asp:Content>

In my content page i have update panel and inside that i have placed a text box.I have also hidden button that is declared as a trigger for the update panel..From modal window i am calling the __doPostBack method using this hidden button.Then onclick event of the hidden button i have written this code

protected void btnNo_Click(object sender,EventArgs e)

{

this.txt2.Text ="From Modal Window";

}

My problem is that this text box is not getiing updated.

Hope the above sample helps you

thanks.

sarthak


Please try this:

master:

<%@. Master Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void btn_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); sb.Append("<script type='text/javascript' language='"); sb.Append("JavaScript'>"); sb.Append("\n"); /************************************************/ sb.Append("var obj = new Object();"); sb.Append("\n"); sb.Append("obj.FirstArg = window;"); /* The above three lines is used to pass the reference of the parent window to the modal window. Using which i can call any javascript function of parent window from my modal dialog window*/ sb.Append("\n"); sb.Append("window.showModalDialog('Forms.aspx', obj, 'status:no; dialogHeight:155px;dialogWidth:510px; help:no; scroll:no; menubar:no; resizable:no');"); sb.Append("\n"); sb.Append("</"); sb.Append("script>"); ScriptManager.RegisterStartupScript(btn, Type.GetType("System.String"), "PopUp", sb.ToString(), false); }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"><title>Menu</title></head><body><form id="form1" runat="server"><asp:ScriptManager ID="Scriptmanager1" runat="server"></asp:ScriptManager><asp:UpdatePanel ID="updMaster" UpdateMode="Conditional" runat="server"><ContentTemplate><div><table border="2" cellpadding="0" style="background-color: #ff3300; width: 345px;" cellspacing="0" ><tr><td align="center" style="width: 164px; height: 26px;"><input type="button" id="btn" name="btn" onserverclick="btn_Click" value="Click" runat="server" /> </td></tr></table></div></ContentTemplate></asp:UpdatePanel><asp:contentplaceholder id="ContentPlaceHolder1" runat="server"></asp:contentplaceholder></form></body></html>
 
Content: 
 
<%@. Page Language="C#" MasterPageFile="~/Menu.master" Title="Untitled Page" %><script runat="server"> protected void btnNo_Click(object sender, EventArgs e) { this.txt2.Text = "From Modal Window"; }</script><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><asp:Button ID="btnNo" OnClick="btnNo_Click" runat="server" style="display:none;"/><asp:UpdatePanel ID="updContent" UpdateMode="Conditional" ChildrenAsTriggers="false" runat="server"><ContentTemplate><table width="340px" border="2" cellpadding="0" cellspacing="0"><tr><td><asp:TextBox id="txt1" runat="server" ></asp:TextBox><td><asp:TextBox id="txt2" runat="server" ></asp:TextBox></td></tr><tr><td></td></tr></table></ContentTemplate></asp:UpdatePanel><script type="text/javascript" >function test(){ window.setTimeout("__doPostBack(invisibleButton.name,'')", 0);}var invisibleButton = document.getElementById('<%= btnNo.ClientID%>');</script></asp:Content>
  Popup:
  
<%@. Page Language="C#" %><!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 id="Head1" runat="server"><title>Forms</title><script type="text/javascript" language="javascript">function PassData(){//window.setTimeout(window.dialogArguments.FirstArg.test(), 500;window.close();}</script></head><body><form id="form1" runat="server"><div><table cellpadding="0" cellspacing="0" border='1' ><tr><td style="width:600px;" align='center' ><table width="500px" cellspacing="2" cellpadding='0' border='0'><tr style="height:10px;"><td style="width: 126px"> </td></tr><tr style="height: 10px"><td style="text-align: center; width: 721px;"><span style="font-size: 11pt; color: #ffffff; font-family: Arial">Do you want to save the changes you have made? </span></td></tr> <tr style="height: 10px"><td style="width: 126px; text-align: center"></td><td style="width: 721px; text-align: center"> <input id="btnNo" type="button" value="Yes" name="Yes" style="width:58px;" onclick="PassData();" runat="server" /> <input id="btnCancel" type="button" value="Cancel" onclick="window.close();" name="Cancel" runat="server" /></td></tr></table></td></tr></table></div></form></body></html>

Hi

Now it is working perfectly.My update panel in the content page is getting updated with the changes.But one thing i would like to know what was wrong with my earlier sample application.In your case i found that all the code i.e for master and content are on the htm design part (inline coding )and while calling the javascript function from popup you have used window.setInterval, and more ever in the content page you have written the javascript function at the end of the update panel , is this making all the differences ??

please clear my doubt on this..

thanks

sarthak


Sarthak,

I get an exception if I call the method directly, so I use a window.setTimeout to defer the invoking.

And it doesn't make any difference if the code is inlined in html or not.


Hello Wen,

what is the exception that u r getting if u call the function directlly.If i don't use window.setinterval i'm not getting any exception, but no data is getting populated.How ever if i use taht it is working perfectly

again thanks a lot for clearing my doubts.

thanks

sarthak

Wednesday, March 21, 2012

Use DynamicPopulateExtender on AccordionPane content

Hi Folks,

Warning: I'm quite new at AJAX so I may be missing something obvious.

I just want to defer population of some AccordionPane conent until the pane is actually clicked. I tried using a DynamicPopulateExtender, but I cant seem to hook up the PopulateTriggerControlID to an AccordianPane(no errors, just doesnt seem to fire). If I hook it up to the Accordian instead, it fires, but oddly enough only fires when clicking the content (any content, of any pane) but not clicking any header, which doesnt do me much good anyway.

See anything i'm missing here? Is there an easy way to do this?

Thanks much in advance, code follows.

Greg

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test dynamic accordian content</title>
</head>
<body>
<form id="form1" runat="server">
<ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server" />
<div>
<ajaxToolkit:Accordion ID="Accordion1" runat="server" SelectedIndex="0" SuppressHeaderPostbacks="True" >
<Panes>

<ajaxToolkit:AccordionPane ID="AccordionPane1" runat="server">
<Header>header1</Header>
<Content>content1</Content>
</ajaxToolkit:AccordionPane>

<ajaxToolkit:AccordionPane ID="AccordionPane2" runat="server">
<Header>header2 </Header>
<Content>
<asp:Panel ID="Panel2" runat="server" Height="50px" Width="100%">static content</asp:Panel>
<ajaxToolkit:DynamicPopulateExtender ID="dp2" runat="server" TargetControlID="Panel2" ServiceMethod="GetHTML" PopulateTriggerControlID="AccordionPane2" />
</Content>
</ajaxToolkit:AccordionPane>

</Panes>
</ajaxToolkit:Accordion>
</div>
</form>
</body>
</html>
<script runat="server">
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string GetHTML(string contextKey)
{
return "some dynamic content"+contextKey;
}
</script>

Hi Greg,

The problem is caused by not specifying correct id. I changed your code a little bit, and place a span element with a specified id in the header. Then use it as the trigger.

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Test dynamic accordian content</title>
</head>
<body>
<form id="form1" runat="server">
<ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server" />
<div>
<ajaxToolkit:Accordion ID="Accordion1" runat="server" SelectedIndex="0" SuppressHeaderPostbacks="True" >
<Panes
<ajaxToolkit:AccordionPane ID="AccordionPane1" runat="server">
<Header>header1</Header>
<Content>content1</Content>
</ajaxToolkit:AccordionPane
<ajaxToolkit:AccordionPane ID="AccordionPane2" runat="server">
<Header>
<span id="hd2">Header2</span>
</Header>
<Content>
<asp:Panel ID="Panel2" runat="server" Height="50px" Width="100%">static content</asp:Panel>
<ajaxToolkit:DynamicPopulateExtender ID="dp2" runat="server" TargetControlID="Panel2" ServiceMethod="GetHTML" PopulateTriggerControlID="hd2" />
</Content>
</ajaxToolkit:AccordionPane
</Panes>
</ajaxToolkit:Accordion>
</div>
</form>
</body>
</html>
<script runat="server">
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string GetHTML(string contextKey)
{
return "some dynamic content" + DateTime.Now.ToString() + contextKey;
}

</script>


Thanks Ramond! You da man!!

Greg