CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > microsoft_downloads.css_friendly_control_adapters Tags:
Item Type: NewsGroup Date Entered: 10/26/2006 3:48:03 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 107 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
Russ Helfand
Asp.Net User
AJAX FIX: UpdatePanel10/26/2006 3:48:03 PM

0/0

This message is for those of you who are attempting to use adapted controls in combination with ASP.NET AJAX beta 1. In particular, some of you have reported (correctly) that the UpdatePanel is triggering full postbacks rather than partial rendering when it wraps something like an adapted GridView.

I have good news and I have bad news.  Which do you want first?

Good news.  I have a fix and will try to get it into the next update of the kit.

Bad news.  It isn't in the kit at this moment, obviously.

Good news. The fix is something you can implement yourself right now by modifying your adapters.

Bad news.  It involves some rather tedious typing.  Personally, I did it over a hot cup of coffee and it wasn't too bad.  I think it took me about 15 minutes.

Here's the the scoop.  ASP.NET AJAX assumes that if there is a control like a GridView on your page (or within an UpdatePanel) then there will be exactly one HTML tag somewhere on the page that has the ClientID of that GridView.  In the unadapted situation, there is a <table> whose id attribute equals the GridView's ClientID.

When you use the adapters as they are written right now the GridView is rendered as a <table> and some wrapping <div> tags.  None of them is given an id equal to the GridView's ClientID.  My initial thinking was naive: nothing needs the ID so why spit it out when it makes the markup look more complex than necessary.

Oooops.

We really do need to put the ClientID of the adapted control onto some tag on the page. That way, dependent tags (like ASP.NET AJAX "extender" tags) can count on being able to find some tag on the page that they can act upon via its unique client id.

It turns out that this will be a relatively simple thing to add to the adapter kit... but it does require a change to the signature of one of the central methods in the kit so we're going to have to update a bunch of calls to that method.  Let me explain.  (I'm going to provide the code here as C# but the fix ultimately will be implemented in the kit in VB.NET, too, of course.)

First, you need to edit App_Code\Adapters\WebControlAdapterExtender.cs.  Locate the method called RenderBeginTag.  Change it to look like this:

        public void RenderBeginTag(HtmlTextWriter writer, string cssClass)
        {
            string id = (AdaptedControl != null) ? AdaptedControl.ClientID : "";

            if (!String.IsNullOrEmpty(AdaptedControl.Attributes["CssSelectorClass"]))
            {
                WriteBeginDiv(writer, AdaptedControl.Attributes["CssSelectorClass"], id);
                id = "";
            }

            WriteBeginDiv(writer, cssClass, id);
        }

Now find the method WriteBeginDiv (in the same file).  Change it to be this:

        static public void WriteBeginDiv(HtmlTextWriter writer, string className, string id)
        {
            writer.WriteLine();
            writer.WriteBeginTag("div");
            if (!String.IsNullOrEmpty(className))
            {
                writer.WriteAttribute("class", className);
            }
            if (!String.IsNullOrEmpty(id))
            {
                writer.WriteAttribute("id", id);
            }
            writer.Write(HtmlTextWriter.TagRightChar);
            writer.Indent++;
        }

Now comes the tedious part.  You need to find every other call to WriteBeginDiv that is in the kit.  And you need to add an extra argument, final argument, an empty string.  The files you need to touch are:

ChangePasswordAdapter.cs
CreateUserWizardAdapter.cs
LoginAdapter.cs
PasswordRecoveryAdapter.cs
WebControlAdapterExtender.cs

So, for example, in ChangePasswordAdapter.cs at line 192, I changed the original call that looked like this:

WebControlAdapterExtender.WriteBeginDiv(writer, className);

to be this:

WebControlAdapterExtender.WriteBeginDiv(writer, className, "");

Notice that I added an new arg to the end of the call's arg list.  It is an empty string, signifying that there is no ID to add to the <div>.  Right now, we only need to add the main ClientID as the id for an outter tag in whatever the adapter renders.

Clear as mud so far? :)

OK, if you do all that and if you use beta 1 of ASP.NET AJAX I think you'll find that UpdatePanel allows partial rendering of adapted controls.  My initial testing shows that to be the case.  However, it would be terrific if Ian or others in the community could provide additional feedback on this.

Regards,


Russ Helfand
Groovybits.com
iclements
Asp.Net User
Re: AJAX FIX: UpdatePanel10/27/2006 8:24:15 AM

0/0

Works like a charm.

 Partial postbacks are now working as expected and I havn't seen any issues.

 The fix is easy and straight forward although the tedious part is pretty tedious :-)

Many thanks, Russ

Edgardo
Asp.Net User
Re: AJAX FIX: UpdatePanel10/27/2006 5:16:24 PM

0/0

Still, I partially agree with this: 

"My initial thinking was naive: nothing needs the ID so why spit it out when it makes the markup look more complex than necessary."

The problem is not that it looks complex, the problem is that all those IDs really add up and the final size of the HTML more heavier that it should be.

I've written adapters for almost every simple web control on the asp.net stack, most of them really don't need the ID attribute on the most common scenarios (for example Image, HyperLink or Label)


-Edgardo
IDisposable
Asp.Net User
Re: AJAX FIX: UpdatePanel10/29/2006 7:48:45 PM

0/0

Now comes the tedious part. You need to find every other call to WriteBeginDiv that is in the kit. And you need to add an extra argument, final argument, an empty string. The files you need to touch are:
You don't have to do all this tedious work if you simply ADD the second overloaded method WriteBeginDiv instead of modifying the existing one.
http://musingmarc.blogspot.com
timgaunt
Asp.Net User
Re: AJAX FIX: UpdatePanel11/21/2006 10:32:53 PM

0/0

Furthermore, I'm using the GridViewAdaptor and have noticed that you're not using this code tweak which had me thinking it was the postback control initially, if you change "RenderBeginTag" in "GridViewAdapter.cs" from:

 

protected override void RenderBeginTag(HtmlTextWriter writer)
{
    if (Extender.AdapterEnabled)
    {
        writer.WriteBeginTag("div");
        writer.WriteAttribute("class", "AspNet-GridView " + gridView.CssClass);
        writer.Write(HtmlTextWriter.TagRightChar);
        Extender.RenderBeginTag(writer, "AspNet-GridView");
    }
    else
    {
        base.RenderBeginTag(writer);
    }
}

  

to:

 

 

protected override void RenderBeginTag(HtmlTextWriter writer)
{
    if (Extender.AdapterEnabled)
    {
        GridView gridView = Control as GridView;
        WebControlAdapterExtender.WriteBeginDiv(writer, "AspNet-GridView " + gridView.CssClass, gridView.ClientID);
    }
    else
    {
        base.RenderBeginTag(writer);
    }
}

  

It seems to sort the issue. In this case I was sorting on the column headers.

HTH

 
Tim 

5 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Programming ASP.NET AJAX Authors: Christian Wenz, Pages: 454, Published: 2007
Enterprise 2. 0 Implementation: Integrate Web 2.0 Services Into Your Enterprise Authors: Aaron Newman, Adam Steinberg, Jeremy Thomas, Pages: 406, Published: 2008
Learning ASP.NET 3.5 Authors: Jesse Liberty, Dan Hurwitz, Brian MacDonald, Pages: 576, Published: 2008
Programmieren mit ASP.net Ajax Authors: Christian Wenz, Pages: 496, Published: 2007
Pro Ajax and the .NET 2.0 Platform Authors: Daniel Woolston, Pages: 463, Published: 2006

Web:
AJAX FIX: UpdatePanel - ASP.NET Forums AJAX FIX: UpdatePanel. Last post 11-21-2006 5:32 PM by timgaunt. 4 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
AJAX Extender for TinyMCE. Including fix for UpdatePanels. - CJ de Vos AJAX Extender for TinyMCE. Including fix for UpdatePanels. The information in this article is no longer valid. Please go to the new version found at ...
#234 (Microsoft Asp.net 2.0 AJAX UpdatePanel Bug) – FCKeditor – Trac 1. FCKEditor.Net 2. FCKEditor.Net inside an UpdatePanel 3. FCKEditor.Net (AJAX fix) inside an UpdatePanel 4. FCKEditor.Net (AJAX fix) *without* UpdatePanel ...
AJAX Extender for TinyMCE. Including fix for UpdatePanels. AJAX Extender for TinyMCE. Including fix for UpdatePanels. The code for the control and a samplewebsite can be downloaded at respectively tinymcetextbox.zip ...
Need to fix validation page on my site with ajax updatepanel asp.net I would like to fix this validation on the site omegalove.com I need to improve this. Any help would be fine. I have put the ascx register page in the ...
CodeProject: Using Validation Controls on an UpdatePanel having ... NET Validation controls used on UpdatePanels in AJAX. .... The essence of the solution was to have a quick fix rather than installing the unoffical patches ...
AJAX UpdatePanel Callback And Expired Forms Auth Ticket re: AJAX UpdatePanel Callback And Expired Forms Auth Ticket. left by Chrys at 12 /10/2007 9:27 PM Gravatar. I have been trying to fix this problem, ...
AJAX UpdatePanel - "Statefull" Control Update Trigger AJAX UpdatePanel - "Statefull" Control Update Trigger - Website Magazine - Website Magazine ... Fixing an ASP.NET 2.0 App after upgrading to 3.5 (15) ...
UpdatePanel Woes - asp.net_ajax.asp.net_ajax_ui - fix error ... AJAX, UpdatePanel, TextEditor woes. Previous. Next. 5/1/2007 8:44 AM . ... Post #1 ... i am having trouble learning how to use the ajax updatepanel. ...
C# Moving list items from one Listbox to another with AJAX ... C# Moving list items from one Listbox to another with AJAX Updatepanels ... Easy fix again, set the listitem.selected property to false before adding it. ...




Search This Site:










cant drag-and-drop web custom control to web form!

creating custom color picklist

building custom controls

injecting custom tags into a datagrid

declaring events for webcontrols inside the sub procedure

license manager attribute question

best website hosting service?

how to create a control/usercontrol that fires events and can be placed on the toolbox

asp.net controls in office 2003 style?

any "good" .net hosts out there?

derived custom controls && composite controls

extending the asp:literal control

server controls with two collection properties

no html-tag and auto complete?

is this type of control creation valid

adding my control icon to the assembly, how !!

dynamic controls on post back?

label in ascx component

asp.net & soap with psoft's h-sphere

header/footer control

alignment of control when cssclass is set

problem in timer function

servervariables object in a server control

free asp.net hosting ??

help! controls problem

databinding checkboxlists

control with children (literal or other controls)

re-instantiate an inherited usercontrol in a repeater

passing parameters to custom server controls

problems with user controls

  Privacy | Contact Us
All Times Are GMT