Showing posts with label newest. Show all posts
Showing posts with label newest. Show all posts

Monday, March 26, 2012

PageMethods....exists different way?

Hi,
i just installed newest version of ASP.NET AJAX and i was looking for an alternative way to PageMethods. PageMethods, if i'm not wrong, work only in page and not in UserControl (i need for that).
I found AjaxNet Pro that permits that but i don't want use other dlls in my project.
Any idea how to call UserControl's Methods with ASP.NET AJAX?

Thanks in adavance ;)

I'm having the same issue. I want to use PageMethods to call my UserControl codebehind methods. Is there a way to do that?

Wednesday, March 21, 2012

partial page rendering with master page... and a broken link in the tutorial

I can't for the life of me figure out how to enable partial page rendering with the newest AJAX release (including the nov. CTP)...

the tutorial speaks to it "If you are working with master pages, you might need to use aScriptManagerProxy control in place of aScriptManager control. For more information, seeHow to: Use Partial-Page Updates in Master Pages.", but you'll notice the link leads to a 404 error.

anyone know the answer to this? I've tried replacing my script manager with a script manager proxy, but the page complains that it needs a script manager first... I'm lost.

Cheers

place the scriptmanager on the masterpage.

place the scriptmanagerproxy on each content page.


you wouldn't happen to have a code example of how to use the proxy manager, would you?

In the Master page, it would be like

<form runat="server">
<asp:ScriptManager id="sm1" runat="server" /
... rest of masterpage markup

</form>

In the content page

<asp:ScriptManagerProxy ID="smp1" runat="server">
<Services>
<asp:ServiceReference Path="~/common/services/ReportData.asmx" />
</Services>
</asp:ScriptManagerProxy>


yeah, that's kinda what I thought... unfortunately (for me!), it's still refreshing the whole page...

hmm... maybe a little more explanation of the page...

I have the script manager in the master page, the proxy manager is in the content page. Also in the content page, I have a GridView in an UpdatePanel. The update panel has an AsyncPostBackTrigger setup on a timer tick, so, I obviously also have a timer on the page (not IN the update panel, it's actually just above it). This used to work perfectly, the grid view would update without refreshing the whole page, users were happy (a near impossibility!), everything was hunky-dory... then I decided to upgrade <grin>.

Any help would be awesome.

Cheers


i dont know why you just don't put the Timer inside the UpdatePanel's Content template, but i'd suggest trying that...

Also this post:
http://forums.asp.net/thread/1452109.aspx

Solved a timer issue i had


wonderbar... works perfectly now.

thanks!


I tried this. It still complains about unknown element 'ScriptMangerProxy'. Any idea why is that? But strange thing is: it compiled.

mbanavige:

place the scriptmanager on the masterpage.

place the scriptmanagerproxy on each content page.

Partial Postback + Extenders (Blast from the Past...)

This seems rather ironic with the issues concerning the extenders after partial postbacks in the newest release. At work, we are still using the CTP release and have not converted to Beta. I am also having problems with my extenders not working after a partial postback. The current page uses 2 main controls. One is a custom control that contains a textbox, calendar, and popup behavior to encapsulate a popup calendar. The other is a custom autocomplete extender. The javascript events are not being fired. (I've verified this by adding debug statements in the javascript that print out if I remove the UpdatePanel, and do not print out when the UpdatePanel is uncommented.

MasterPage's ContentTemplate
--UpdatePanel
--table
--tr
---td
----DetailsView
----Row
-----PopupCalendar Control
----Row
-----Custom AutoComplete
----GridView

I saw one post saying that it was the table causing the problem and that making the table runat="server" fixed his/her problem. Lucky him/her. If the DetailsView uses DefaultMode="edit", then both controls work. If I start in ReadOnly mode and use a partial postback to switch...no-go.

I know that this is an older release, but if anyone has any thoughts or experienced this when they were using the last pre-beta CTP release, I'd really appreciate some help before I rip all of my hair out.

Thanks.

I suspect the problem here is that the UpdatePanel doesn't understand the dynamic loading of the components, which probabaly happens in PreRender after the UpdatePanel has scanned the tree. So when the DetailsView switches modes and popuplates itself, it's too late. Unfortuantely, I'm not sure how to fix it.

One thing you can try is calling DetailsView1.DataBind() in Page_Load.


I had a similar problem with the AccordionExtender in an UpdatePanel and created the following workaround:

1) Get control toolkit source code

2) Add the following class under AjaxControlToolkit\ExtenderBase\ExtendedScriptBehaviorDescriptor.cs:

using System;using System.Collections.Generic;using System.Text;using Microsoft.Web.UI;namespace AjaxControlToolkit.ExtenderBase{/// <summary> /// This is merely a hack to overcome the known limitation of the Ajax 1.0 Beta 2 /// that it is impossible to use control extenders inside UpdatePanel because /// the correspondend Behavior instance is being lost after the async postback. /// The workaround is to register an event handler on page load event of the /// PageRequestManager and to re-create the behaviour in this event handler. /// This class has been only tested for an Accordion control inside UpdatePanel. /// </summary>class ExtendedScriptBehaviorDescriptor: ScriptBehaviorDescriptor {public ExtendedScriptBehaviorDescriptor(string type,string elementID):base(type, elementID) { }protected override string GetScript() {string answer =base.GetScript() +" Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded("+"function (sender, args) {"+" var myBehaviors = Sys.UI.Behavior.getBehaviorsByType($get('" +this.ElementID +"'), " +this.Type +");" +" if(myBehaviors.length == 0) {"+base.GetScript() +" }"+"});";//Known limitation / bug: if you register several extenders of the same type //for the same DOM element, only one of them (anyone) will be re-created //after async postback. Can be easily fixed using a slightly more complex //checking logic in the javascript above.return answer; } }}

3) Find the method GetScriptDescriptors in ExtenderControlBase and change the following:

//Original code (before patch): //ScriptBehaviorDescriptor descriptor = // new ScriptBehaviorDescriptor(ClientControlType, targetControl.ClientID); ExtendedScriptBehaviorDescriptor descriptor =new ExtendedScriptBehaviorDescriptor(ClientControlType, targetControl.ClientID);

4) Compile the control toolkit, reference the new version in your project and try if it works now.

You can use the new class also with extenders not using ExtenderControlBase from the Control Toolkit.


Neat! I've openedwork item 6063 to track this.

Sorry for the delay in replying, I ditched college for the week and went home for Thanksgiving.Wink. Calling DataBind on the DetailsView in the PageLoad event didn't work. Random thought: to match other pages in the project, both the details view and gridview are in the same update panel. I wonder if separating so that the dv and gv each have their own update panel would make a difference.

*starts muttering and switches back to VS.

Edit: If I use DefaultMode="Edit" for the DetailsView, click in the textbox to bring up the popup calendar, and click to advance the month, I get the following:

Alert


In the pre-beta CTP, there is no ScriptBehaviorDescriptor, so if this is even a possible hack, it will need to be a hack of a hack. Is there a CTP equivalent?


We recommend using the latest Beta. There may be issues that would require more investigation using the ctp. A lot of changes were made just to get the toolkit working at the asp.net ajax beta so it would be best to move to the beta and then pursue this investigation.