Showing posts with label controls. Show all posts
Showing posts with label controls. Show all posts

Wednesday, March 28, 2012

Extending Server Controls?

I see this blurb on the tutorials section:

"Extend server controls or control extenders: You might create new behaviors for given server controls by implementing a server control that also implements the IScriptControl to render the ASP.NET "Atlas" client script and register with the ScriptManager in the Web page. Page developers will gain from specific new server-side controls without needing to write ASP.NET "Atlas" script or JavaScript."

This is great to hear, anyone know how this works? ie. I see it says I don't need to write script at all?

Let's say I wanted a input mask textbox - how would I 'extend' the TextBox using IScriptControl and do this code without writing script?

Hi,

check alsothis article from my blog for an introduction to extenders.

Extending CascadingDropDown to update other controls

My idea:

I have a basketball stats website that I'm trying to migrate to AJAX due to its no-postback. I have an "Add Game" page, in which I want to have the user select a team from a drop down list, but then I want to populate a control other than a drop down list (perhaps just a list of some sort, so the user can see all the options). The CascadingDropDown control in the AJAX toolkit accomplishes this for drop down lists, but I'm wondering if it could be extended to other controls?

I hope all of this makes sense. I'm open to more questions if it's unclear.

Thanks.

Tony

Hi,Tony

I am afraid we cannot find out the exact root cause without further information captured when the problem occurs.

To troubleshoot this issue, we really need more source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

Thank you.

Extenders NOT Doing Anything?

I've just reviewed "#36 – How Do I: Use the ASP.NET AJAX MaskEdit Controls?". I ran the finished sample code (as downloaded) on VWD 2005 EE and it all works "as advertised" – all of the functionality is definitely there.

HOWEVER, when I copied the project file up to TWO different hosting services (both equipped with the current "AjaxControlTookit.dll" [and dll.refresh] and ".pdb" files in a "/Bin" directory at the root level of the logical "wwwroot" the application starts without error but then nothing really IS "extended" in the three sample Textbox controls. HUH? I emphasize that this happens on TWO separate hosting services (one if GoDaddy which has been shown to work with ASP.NET 2 and the other is on UltimaHosts.net which has also run 'normal' ASP.NET 2 applications).

I fear I'm missing something fundamental here. Any ideas?

Mahalos in advance …J KevInKauai

Does the bin folder also contain the 2 dll's for the ajax core?

System.Web.Extensions.dll

System.Web.Extensions.Design.dll


Hi, Wim, and thanks for the attempt at guidance.

I'm unclear about whether you mean a "/Bin" directory beneath each Application/Project or at the root of the web site (which is what I have). (It would seem awfully space-consuming to have to have it in EACH Application/Project, right?)

Here's what I've got:

problem summation

SO WHERE'S the handy-dandy goof-proof "guide to deploying ASP.NET/AJAX-ified applications on your Server" ?

The devil seems to be in the details, as usual!

mahalo for any guidance ... :) KevInKauai

P.S. The results are identical in the following browsers: FireFox 2.0, IE 70.5730.11 and Safari PC 3.0 (522.11.3).


Hi,

You'd better install the Ajax extension on the server first. It can be downloaded here: http://ajax.asp.net/downloads/default.aspx?tabid=47


Hi, Raymond - -

Do the screen captures above not show that the "required" libraries are there? According to my download directory, I downloaded "ASPAJAXExtSetup.msi" (around May 15) and ran into, then used what I assumed are the required items (as indicated in the screen shots).

I don't think you're telling me to download this again "just for fun", are you?

Mahalo ... :) KevInKauai


Hey,

Ok, A website has a bin directory: For example: c:\Inetpub\wwwroot\MyWebSite\bin
The above tells me I have a website called MyWebSite and it has a bin-folder.

I don't think that MyWebSite can use a bin folder located here: c:\Inetpub\wwwroot\bin
AND that is just what your pictures tell me. So the bin folder should be inside the WebSite directory.

If you want to use dll's for more applications and you don't want to copy the dll's to every bin of every website that uses them, you should install those dlls in the GAC (Global Assembly Cache).

Note that the dll's you want to use in serveral applications should be installed in the GAC of the WebServer.

Also note that the installation of dll's in the GAC is best done by using the GACUTIL.EXE utility which can be started from command line.

Hope this helps!
Wim


KevInKauai:

Hi, Raymond - -

Do the screen captures above not show that the "required" libraries are there? According to my download directory, I downloaded "ASPAJAXExtSetup.msi" (around May 15) and ran into, then used what I assumed are the required items (as indicated in the screen shots).

I don't think you're telling me to download this again "just for fun", are you?

Mahalo ... :) KevInKauai

The point of my suggestion is that it's not sufficient to deploy it by simply putting it in the bin folder. Because some of the operations performed by the AJAX extension require full trust permission. To install it will installer will add it into GAC automatically and run with full trust permission.

You can try Wim's suggestion to install it into GAC manually.

You may also tryconfiguringyou web application to run in full trust mode in web.config.


Raymond Wen - MSFT:

The point of my suggestion is that it's not sufficient to deploy it by simply putting it in the bin folder.

Hey Raymond,

Ok, this is a bit off topic, but on my webserver, their is NO Ajax, nor the toolkit installed, and just by putting the 2 ajax dll's and the toolkit dll in the binfolder of my website on the webserver, all the ajax and toolkit functionallity works!

Greetz,
Wim


Hi, Wim - -

Thanks for your pointers and perhaps I should have made it clearer that I'm in a "shared hosting" situation -- where I do not control things like whatever the "GAC" is. According to their notes on AJAX, they have installed "what you need" there. It's the add-on stuff that wants a proper home. I had assumed that ONE /Bin directory at the root of my website (which has old-time FrontPage things which want to be calling out to new-style ASP/AJAX application pages) would suffice.

Are you saying that each application sub-directory is going to need a /Bin with extra copies of these various AJAX components?

If anyone knows where the CLEAR and SIMPLE "How to use AJAX in a Shared Hosting Environment" installation guide is, I'd sure appreciate a push in that direction!

Mahalo ... :) KevInKauai


KevInKauai:

Are you saying that each application sub-directory is going to need a /Bin with extra copies of these various AJAX components?

Hi,

For as far as I know this is going to be the procedure. If someone else knows a way to create a central storage for application-wide-dll's, please let us knowWink (it has to be possible :) )

Normally the GAC offers a solution to store application wide dll's in one place. But for shared hosting where you don't have full control over the webserver that isn't so easy.

Extenders in Composite/Custom Controls

I've created composite or custom controls with ajaxcontrol extenders, example is a textbox with FilteredTextBoxExtender. So far I am able to make the new control work.

My problem is how to expose the extender's properties that are of enumeration type like the FilterType where you can assign more than one value in comma delimited format (ex. "Number, Custom" or "UppercaseLetters, Custom")

I think it is not possible to directly access the childcontrol's (the extender) properties from the class, so how do I create a property that do the same as the extender's property?

I looked into the code of the AjaxControlToolkit, in C# its

[ExtenderControlProperty]

[DefaultValue(FilterTypes.Custom)]

publicFilterTypes FilterType

{

get {return GetPropertyValue<FilterTypes>("FilterType",FilterTypes.Custom); }set { SetPropertyValue<FilterTypes>("FilterType",value); }

}

I need a code for vb.net, I also tried converting the code using some online conversion tool but the result is not working. Here's the result:

<ExtenderControlProperty()> _

<DefaultValue(FilterTypes.[Custom])> _

PublicProperty FilterType()As FilterTypes

Get

Return GetPropertyValue(Of FilterTypes)("FilterType", FilterTypes.[Custom])

EndGet

Set(ByVal valueAs FilterTypes)

SetPropertyValue(Of FilterTypes)("FilterType", value)

EndSet

EndProperty

----

Any help is appreciated.

Solved.

Sometimes you just need to take a break to clear your mind. I was making my code complicated. :)

Extenders for controls inside TabContainer/TabPanel

Hi,

I have a textbox control (ID="'PasswordTxtBox' ") inside TabPanel and I am trying to attach watermark extender to it. In design mode TargetControlID for watermark extender does not appear and when I manually write it in the markup I get run time error saying

The TargetControlID of 'TextBoxWatermarkExtender1' is not valid. A control with ID 'PasswordTxtBox' could not be found

Please guide.

Regards & thanks

Kapil

My bad. I was _not_ putting the extender control in the contenttemplate of tabpanel.

Regards

Kapil

Extender TargetControlId not sufficient enough to reference controls not in NamingContaine

Through reflection i see OnPreRender searches for a TargetProperty's TargetControl via its TargetControlID.
It only searches in NamingContainer of the Control this Extender is contained in.
I need ExtenderProperty to take both a NamingContainer and a TargetControlID so I can extend objects directly
on the page when this Extender may appear in a subcontrol.
Are ther plans to support extending Controls outside of the parent's NamingContainer space?
protectedoverridevoidOnPreRender(EventArgs e){base.OnPreRender(e);if ((this.._page;" href="http://links.10026.com/?link=http://www.aisto.com/roeder/dotnet/Default.aspx?Object=4">_page ==null) && (this.Page !=null)) {this.._page;" href="http://links.10026.com/?link=http://www.aisto.com/roeder/dotnet/Default.aspx?Object=6">_page =newPageWrapper(this.Page); }ScriptManagermanager1 =ScriptManager.GetCurrent(this.._page;" href="http://links.10026.com/?link=http://www.aisto.com/roeder/dotnet/Default.aspx?Object=12">_page);if (manager1 ==null) {thrownewInvalidOperationException("You must have a ScriptManager to use an ExtenderControl."); }Controlcontrol1 =this.NamingContainer;using (" href="http://links.10026.com/?link=http://www.aisto.com/roeder/dotnet/Default.aspx?Object=16">IEnumerator<T>enumerator1=this. Microsoft.Web.UI.ExtenderControl.TargetProperties { ... }" href="http://links.10026.com/?link=http://www.aisto.com/roeder/dotnet/Default.aspx?Object=17">TargetProperties. System.Collections.ObjectModel.Collection.GetEnumerator();" href="http://links.10026.com/?link=http://www.aisto.com/roeder/dotnet/Default.aspx?Object=18">GetEnumerator()) {while ( enumerator1 // Local Variable">enumerator1.MoveNext()) {Tlocal1 = enumerator1 // Local Variable">enumerator1..get_Current();" href="http://links.10026.com/?link=http://www.aisto.com/roeder/dotnet/Default.aspx?Object=20">get_Current();Controlcontrol2 =control1.FindControl(local1.TargetControlID);if (control2 !=null) {IScriptControlcontrol3 =manager1.RegisterControl(control2);control3.RegisterBehavior(this);continue; }thrownewInvalidOperationException(string.Format(CultureInfo.InvariantCulture,"Target control with ID '{0}' could not be found for extender '{1}'.",newobject[] {local1.TargetControlID,this.ID })); } }}

The Toolkit doesn't actually run this code - we have an override that will also search for controls at the page level.

Even if the extenders took a NamingContainer property, it doesn't fix the problem. NamingContainers can be nested, so you could end up in the same situation where you can't find the naming container.

In the May 4th release of the Toolkit, we added a "ResolveTargetControlID" event that you can handle to do these types of resolutions yourself. The if the extender can't locate the Control referenced by TargetID, this event will fire and you can return the control instance.

Extender for two controls (Toggle-able Collapsible Panels)

I'm looking to build my first extender and the one I've chosen is a variation on the CollapsiblePanel so I've started with that control as my base. I've removed the ExpandControlID property and forced the CollapseControlID to always be a toggle. I've also added a property, CollapsePanelID, which is the ID of a second panel. At startup, the TargetControlID is expanded, the CollapsePanelID is collapsed and the CollapseControlID is used to toggle the two of them together.

I'm having trouble setting up the animation for the second panel. For the first, I see the line:
_animation.set_target( this );
I can't figure out how to call a similar function for the CollapsePanelID. I thought maybe there was a Sys.UI.Panel object I could create and configure for the second panel but I don't see one. The idea is that I would set up a second animation for the second panel, then in the _doOpen and _doClose functions, I'd play it along with the existing one.

This is for my own edification, not for any specific problem. I've already been able to do this functionally with two CollapsiblePanels. Just picked this as my project for learning extenders. Even as I write this, I'm thinking there might be a better way to do this but it would still involve the ability to create a Sys.UI control that maps to an asp:panel object.

Thanks,
Kyle

Hi Kyle,

Check out the JavaScript inFAQ item #13. It does essentially what you want - given an ID"Link1" it creates a newSys.UI.Control wrapper for it. This is what you need to pass intoset_target.

It's also worth mentioning that we've got a similar control in the works for the next release of the Toolkit. You check it out in the Prototypes project on CodePlex if you're interested.

Thanks,
Ted

Thanks, Ted. That FAQ item does look like what I want. I'll check it out.

Downloaded the source from CodePlex and had trouble opening the Prototypes project ("The project type is not supported by this installation"). I'll get it worked out but thought I'd raise the issue.

Thanks again,
Kyle


Never mind about the error. Read the instructions, installed the web app update and all is well.

Extender controls of type AjaxControlToolkit.DragPanelExtender cannot extend controls of t

Hi, I'm getting this error when trying to port an old Atlas Web App to use the latest bits - any help would be nice as to what controls I CAN extend - so if I can't use a DIV what then?:

Server Error in '/GRintranets' Application.

Extender control 'DragPanelExtender1' cannot extend 'divPaginaHTML'. Extender controls of type 'AjaxControlToolkit.DragPanelExtender' cannot extend controls of type 'System.Web.UI.HtmlControls.HtmlGenericControl'.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.InvalidOperationException: Extender control 'DragPanelExtender1' cannot extend 'divPaginaHTML'. Extender controls of type 'AjaxControlToolkit.DragPanelExtender' cannot extend controls of type 'System.Web.UI.HtmlControls.HtmlGenericControl'.

Source Error:

Line 368: {Line 369:// EnsureProfileScriptService(ScriptManager.GetCurrent(Page), true);Line 370: base.OnPreRender(e);Line 371:Line 372: if (Enabled && TargetControl.Visible)


Source File:E:\My Documents\Visual Studio 2005 Projects\2007\CS\01 - ene2\AjaxControlToolkitSln\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs Line:370

Stack Trace:

[InvalidOperationException: Extender control 'DragPanelExtender1' cannot extend 'divPaginaHTML'. Extender controls of type 'AjaxControlToolkit.DragPanelExtender' cannot extend controls of type 'System.Web.UI.HtmlControls.HtmlGenericControl'.] System.Web.UI.ScriptControlManager.VerifyTargetControlType(TExtenderControl extenderControl, Control targetControl) +262 System.Web.UI.ScriptControlManager.RegisterExtenderControl(TExtenderControl extenderControl, Control targetControl) +74 System.Web.UI.ScriptManager.RegisterExtenderControl(TExtenderControl extenderControl, Control targetControl) +104 System.Web.UI.ExtenderControl.RegisterWithScriptManager() +177 System.Web.UI.ExtenderControl.OnPreRender(EventArgs e) +17 AjaxControlToolkit.ExtenderControlBase.OnPreRender(EventArgs e) in E:\My Documents\Visual Studio 2005 Projects\2007\CS\01 - ene2\AjaxControlToolkitSln\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs:370 System.Web.UI.Control.PreRenderRecursiveInternal() +77 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360



Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

just use an <asp:Panel> control


Thanx Shawn - it works fine now but it doesn't seem to respect the z-index: 999 I'm assigning it (I tried through 'Style' and 'cssClass') - the thing is the window disappears behind other controls.

Could you say something useful about how to go to not let the draggable asp:Panel disappear behind the other page controls? I have explicit a very high value for the z-index but it won't stay on top. TIA

FYI, the page is loaded through AJAX in an iframe inside a table (on a page that uses a MasterPage), like this:

<tr><tdcolspan="10"style="height: 710px; width: 100%; z-index: 999;"valign="top"><!--content-->

<iframerunat="server"frameborder="0"id="ifContent"style="z-index: 999; width: 100%; height: 100%;"/>

<!--content--></td></tr>

Then, the page contains among other controls this combination of controls where I load content from a document in the iframe and make dragging possible through the inner asp:Panel:

<asp:Panelrunat="server"ID="pnlPaginaHTML"CssClass="cssPnlPaginaHTML"Style="z-index: 999">

<asp:PanelID="pnlLeer"runat="server"BackColor="Gray"Style="left: 12px; position: absolute; top: 5px; width: 828px; height: 16px"><spanstyle="font-size: 8pt"> se puede mover la ventana con el mouse rastreando la ventana en esta barra gris</span></asp:Panel><iframerunat="server"id="ifrPaginaHTML"src="#"scrolling="auto"style=" z-index: 999; left: 11px; width: 829px; position: absolute; top: 26px; height: 612px;"frameborder="1"></iframe></asp:Panel><atlas:DragPanelExtenderID="DragPanelExtender1"runat="server"TargetControlID="pnlPaginaHTML"DragHandleID="pnlLeer"></atlas:DragPanelExtender>

Extender Controls not compiling

Hello ,

I recently started working with Ajax/Atlas. I have set up atlas extensions , and am trying to add the control toolkit . I follwoed the instructions , The items show up in the toolbox. When I drag any of the controls onto a webform . Intellisense tell me that the control is not a known element.

I realize this is vague, but if anyone can point me in the right. direction .

Thanks in advance

It seems to be related to how the controls are registered in the site . I have opened other sample projects where the controls are being used and they work fin, in that project .

Extender controls may not be registered before PreRender.

Anytime I insert a calendar extendar control or any other control from the Ajax toolkit in gridview or detailsview template. I get the page exception error. "Extender controls may not be registered before PreRender". I am using the latest Atlas DLL's.

I noticed other posts about the same subject but no clear or detailed answer to the solution. Any help will be greatly appreciated. Preferebly in vb.net please.

Hi,

by "latest Atlas DLL" do you mean ASP.NET AJAX 1.0 ?


Yes,

I meant ASP.NET AJAX 1.0 Garbin. Thanks for the offer to help. I did eventually found the fix for this problem by trial and error. I simply took the ScriptManager out of the Detailsview Control -Insertview section and placed it on the page I had the Detailsview control and Walla! problem resolved. I am sure this is probably cheating but hey it worked. If anybody has any insight as to why this happens and what is the right fix for it please enlight us all.

Once again to recreate the problem try the following steps.

1. Drag and drop a detailsview control on your page.
2. Bind the detailsview control to any datasource.
3. In Detailsview Insert mode drag and drop a textbox then any drag and drop any Atlas control ( I tried Calendar Extendar) right inside the Detailsview insert item template.
4. Bind Calendar extender to the Textbox.
5. Preview your page on your web browser and you will see the ugly exception "Extender controls may not be registered before PreRender."


Hi,

I'm not sure why it's happening, but the ScriptManager control should always be declared in the page (or in the Master Page) rather than in a control's template.


Thanks man! This fixed my problem.

I ran into this problem after I added a Login Control on my Master Page. I had to move my script manager from my "inner page" into my Master Page and that fixed the problem.

Cheers!

Extender controls arent actually doing anything??

Everything builds correctly but I'm haven't seen any of the extender features in action.

I have a text box and a watermark extender. Nothing happens when I view the page... Also when I tried to run the examples the extender features didn't work there either... Its seems like I'm missing something somwhere... (maybe I need to copy some script files to an asp.net folder or place the ajaxcontroltoolkit.dll somewhere)

Here's what I did for installation:
Downloaded the examples from herehttp://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=AtlasControlToolkit to my desktop
Grabbed the ajaxcontroltoolkit.dll and dragged it to my toolbox of visual studio

Lastly... my other ajax stuff is working fine (using script manager and updatepanel)
Maybe there's an installation package for the ajaxcontroltoolkit that I missed.

Here's my sample page:

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

<asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager>
<ajaxToolkit:TextBoxWatermarkExtenderID="TextBoxWatermarkExtender1"runat="server"TargetControlID="TextBox1"WatermarkText="test"></ajaxToolkit:TextBoxWatermarkExtender>
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox></form>

Thanks,
Paul

well... uninstalling and reinstalling everthing ajax related fixed it

extender control inside databound controls

I will show you a piece of code that worked with the last CTP:

<%@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="test.aspx.cs"Inherits="test" %>

<!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>Databound Controls</title>

</head>

<body>

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

<atlas:ScriptManagerEnablePartialRendering=trueID="sm"runat="server"></atlas:ScriptManager>

<

asp:RepeaterID="rpt"runat="server"DataSourceID="xmlData"OnItemDataBound="rpt_ItemDataBound">

<ItemTemplate>

<%# XPath("name") %><asp:TextBoxID="textInside"runat="server"></asp:TextBox><br/>

<atlastoolkit:TextBoxWatermarkExtenderID="watInside"TargetControlID="textInside"runat="server"WatermarkText="Inside TextBox"/>

</ItemTemplate>

</asp:Repeater>

Somebody<asp:TextBoxID="textOutside"runat="server"></asp:TextBox><br/>

<atlastoolkit:TextBoxWatermarkExtenderID="watOutside"runat="server"TargetControlID="textOutside"WatermarkText="Outside TextBox"/>

<asp:XmlDataSourceID="xmlData"runat="server"XPath="contacts">

<Data>

<contacts>

<name>Peter</name>

</contacts></Data>

</asp:XmlDataSource>

</form>

</body>

</html>

This piece of code is not working anymore more. The responsible is the “new” behaviour of the TargetControlID. Now, you need the ClientID of the target control, not the usual control ID.

In the easy case, both (ClientID and ID) are the same, but not inside databound controls. So what you need now is:

First, you need to DataBind() the Page at load stage; this is because you need the extender controls in the control tree before the (Pre)Render stage; otherwise, they won’t render.

Second, you need to delete the TextBoxWatermarkExtender instantiated declaratively, and add it at runtime:

protectedvoid rpt_ItemDataBound(object sender,RepeaterItemEventArgs e)

{

AjaxControlToolkit.TextBoxWatermarkExtender tbe =new AjaxControlToolkit.TextBoxWatermarkExtender ();

tbe.TargetControlID = (e.Item.FindControl("textInside")asTextBox).ClientID;

tbe.ID ="watInside";

tbe.WatermarkText ="Inside Text";

tbe.ResolveControlID +=new AjaxControlToolkit.ResolveControlEventHandler(tbe_ResolveControlID);

e.Item.Controls.Add(tbe);

}

Finally, the extender control is not still able to find the TargetControlID, so you have to make up your own FindControl (like this one) :

void tbe_ResolveControlID(object sender, AjaxControlToolkit.ResolveControlEventArgs e)

{

e.Control =Util.FindControl(e.ControlID,"_",this.Page);

}

publicstatic System.Web.UI.Control Util.FindControl(string cliendid,string separator, System.Web.UI.Control root)

{

int i = 0;

string[] sepControls = cliendid.Split(separator[0]);

System.Web.UI.Control fc =null;

for (fc = root; (null != fc) && i < sepControls.Length; i++)

{

fc = fc.FindControl(sepControls[i]);

}

if (fc !=null && fc.ClientID == cliendid)return fc;

elsereturnnull;

}

If someone knows any other way to simplify this case, please tell me. Otherwise, my project has become a nightmare.

fran

Your original sample works fine for me with the addition of only:

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
rpt.DataBind();
}

More details here:http://forums.asp.net/thread/1441672.aspx.

Extender control ... cannot extend controls of type ...

Hi all,

I have a custom ImageButton that inherits from the standard ImageButton.

When I try to extend this button with ConfirmButtonExtender, I receive the following error:

Extender control 'cbeDelete' cannot extend 'ibDelete'.
Extender controls of type 'AjaxControlToolkit.ConfirmButtonExtender' cannot extend controls of type 'MyControls.ImageButton'.

Thx in advance

Any suggestions?

Even I am having same problem.

Extended controls may not be registered before Pre-Render

hi all,

i get the following error message when trying to load a usercontrol containing a modalpopupextender:
"extended controls may not be registered before pre-render"

no line specified, no more info about what's wrong, and almost everything is done with click 'n' drag in design mode (vwd 2005).

default.aspx and its codebehind:http://www.aspsidan.se/code/default.asp?c=9359

editcontent.ascx and its codebehind:http://www.aspsidan.se/code/default.asp?c=9361

the error message:http://www.aspsidan.se/code/default.asp?c=9360

editcontent.ascx is, as you can see, within a loginview, and it's not until i log on that i get the problem. i guess this error has something to do with the page life cycle, but i have no clue of how to get around it...

(i posted the code already in another forum, so i refer to those pages. i hope they're available even if you're not logged on. i've tried when i was offline and it worked, so it shouldn't be a problem...)

Hi lycken,

It is a common issue. You should add base.OnPreRender at the beginning ofvoid OnPreRender(EventArgs e){};

For more , pleaseread this. If it doesn't work, please feel free to let me know.

Best regards,

Jonathan


hi jonathan,

thanks a lot for the reply! it really does save my day that there is a solution to this.

however, neither your answer nor the article you linked me to helped me all the way. i understand i have to call the base.OnPreRender routine, but i can't figure out where in my code to put the call. i am coding in vb, so if you could explain it with vb examples instead of c# it would help me ;)

thanks again for your help!

-tomas


Hi Lycken,

Would you please give us a tiny and workable repro? So you can benefit from it directly. Thanks for your understanding.

Best regards,

Jonathan


hi again jonathan,

i provided all my source code in the first post - unless the links are not working. it's pasted below anyway - excuse the lenghtyness... and again - thanks for helping out!

the db is designed as follows:

Texts
******
TextID | int (identifier, primary key)
TextName | varchar(15)
Text | varchar(max)

Default.aspx

1<%@. Page Language="VB" MasterPageFile="~/site.master" AutoEventWireup="false" CodeFile="Default.aspx.vb"Inherits="_Default" title="Untitled Page" Theme="SMK" Trace="true" %>
2<%@. RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
3<%@. Register TagPrefix="list" TagName="Concerts" src="~/konsertprogram/Concerts.ascx" %>
4<%@. Register TagPrefix="ucl" TagName="EditContent" src="~/admin/EditContent.ascx" %>
5
6<asp:Content ID="Content1" ContentPlaceHolderID="Left" Runat="Server">
7 <asp:Image ID="LeftPaneImage" runat="server" ImageUrl="~/image/bredvid_konserter.jpg" />
8</asp:Content>
9<asp:Content ID="Content2" ContentPlaceHolderID="Content" Runat="Server">
10 <asp:Label ID="TextLabel" runat="server" />
11 <div style="text-align:right; width:100%;">
12 <asp:LoginView ID="LoginView1" runat="server">
13 <RoleGroups>
14 <asp:RoleGroup Roles="Admin">
15 <ContentTemplate>
16 <ucl:EditContent ID="EditContentUserControl" runat="server" TextToEdit="hem" />
17 </ContentTemplate>
18 </asp:RoleGroup>
19 </RoleGroups>
20 </asp:LoginView>
21 </div>
22
23 <div class="row">
24 <div style="float:left;">
25 <h1>N?sta konsert:</h1>
26 <list:Concerts ID="Concerts" runat="server" ItemsToShow="1" />
27 </div>
28
29 <div style="float:left;">
30 <h1>En till ruta</h1>
31 <p>med lite info</p>
32 </div>
33 </div>
34
35</asp:Content>

Default.aspx.vb

1Imports System.Configuration
2Imports System.Data.SqlClient
3Imports System.Data.SqlDbType
4Imports ErrorHandling
5
6PartialClass _Default
7Inherits System.Web.UI.Page
8
9Dim objConnAs New SqlConnection(ConfigurationManager.ConnectionStrings("SMK").ConnectionString)
10
11Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.Load
12Dim objCmdAs New SqlCommand("SELECT [Text] FROM [Texts] WHERE [TextName] ='hem'", objConn)
13
14Try
15 objConn.Open()
16 TextLabel.Text = StringFunctions.FormatText(objCmd.ExecuteScalar)
17Catch exAs Exception
18 Err.Log(ex)
19Finally
20 If objConn IsNotNothing Then objConn.Close()
21End Try
22 End Sub
23End Class

EditContent.ascx

1<%@. Control Language="VB" AutoEventWireup="false" CodeFile="EditContent.ascx.vb"Inherits="admin_EditContent" %>
2<%@. RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
3<asp:ScriptManager ID="ScriptManager1" runat="server">
4</asp:ScriptManager>
5<asp:LinkButton ID="EditText" runat="server" CssClass="textr">Redigera texten</asp:LinkButton>
6<asp:Panel ID="ModalPanel" runat="server" CssClass="modalpu">
7 <asp:Button ID="btnBold" runat="server" Font-Bold="True" Text="F" Width="30px" />
8 <asp:Button ID="btnItalic" runat="server" Font-Italic="True" Text="K" Width="30px" />
9 <asp:Button ID="btnUnderline" runat="server" Font-Underline="True" Text="U" Width="30px" />
10 <asp:Button ID="btnHeader" runat="server" Text="Rubrik" Width="80px" />
11 <asp:Button ID="btnText" runat="server" Text="Text" Width="80px" /><br />
12 <asp:TextBox ID="tbContent" runat="server" Height="400px" Width="430px" TextMode="MultiLine" /><br />
13 <asp:Button ID="OKButton" runat="server" Font-Bold="True" Text="Skicka" Width="90px" />
14 <asp:Button ID="CancelButton" runat="server" Text="Avbryt" Width="90px" /><br />
15 <asp:Label ID="lblStatus" runat="server" />
16</asp:Panel>
17<cc1:ModalPopupExtender ID="ModalPopupExtender" runat="server"
18 TargetControlID="EditText"
19 PopupControlID="ModalPanel"
20 x="0"
21 Y="0"
22 DropShadow="true"
23 RepositionMode="none"
24 OkControlID="OKButton"
25 OnOkScript="__doPostBack('ctl00$Content$LoginView1$EditContentUserControl$OKButton','')"
26 CancelControlID="CancelButton"
27 BackgroundCssClass="modalbg" />
EditContent.ascx.vb
1Imports System.Configuration
2Imports System.Data.SqlClient
3Imports System.Data.SqlDbType
4Imports ErrorHandling
5
6PartialClass admin_EditContent
7Inherits System.Web.UI.UserControl
8
9Dim objConnAs New SqlConnection(ConfigurationManager.ConnectionStrings("SMK").ConnectionString)
10Private _textToEditAs String
11
12 Public WriteOnly Property TextToEdit()As String
13 Set(ByVal valueAs String)
14 _textToEdit = value
15End Set
16 End Property
17
18 Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.Load
19Dim objCmdAs New SqlCommand("SELECT [Text] FROM [Texts] WHERE [TextName] = @.TextName", objConn)
20
21Dim objParamAs New SqlParameter("@.TextName", VarChar)
22 objParam.Value = _textToEdit
23 objCmd.Parameters.Add(objParam)
24
25Try
26 objConn.Open()
27 tbContent.Text = objCmd.ExecuteScalar
28Catch exAs Exception
29 Err.Log(ex)
30Finally
31 If objConn IsNotNothing Then objConn.Close()
32End Try
33 End Sub
34
35 Protected Sub OKButton_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles OKButton.Click
36Dim objCmdAs New SqlCommand("UPDATE Texts SET [Text] = @.Text WHERE [TextName] = @.TextName", objConn)
37
38Dim objParamAs New SqlParameter("@.Text", VarChar)
39 objParam.Value = tbContent.Text
40 objCmd.Parameters.Add(objParam)
41
42 objParam =New SqlParameter("@.TextName", VarChar)
43 objParam.Value = _textToEdit
44 objCmd.Parameters.Add(objParam)
45
46Try
47 objConn.Open()
48 objCmd.ExecuteNonQuery()
49 lblStatus.Text ="Uppdaterat!"
50Catch exAs Exception
51 Err.Log(ex)
52Finally
53 If objConn IsNotNothing Then objConn.Close()
54End Try
55
56 objConn =Nothing
57 objCmd =Nothing
58 End Sub
59End Class



Hi Luken,

Would you please add this code to EditContent.ascx.vb?

protected override void OnPreRender(EventArgs e)
{
// add base.OnPreRender(e); at the beginning of the method.
base.OnPreRender(e);

// codes to handle with your controls.
...
}

I have copied your code to my project and did some modifications(comment and rename work only) , it works well on my machine. Also where's your master page? If it doesn't work, would you please create aworkable sample and give us the links so that we can download your project. Thanks

Best regards,

Jonathan


i'd love to add it to editcontent.ascx.vb, but i don't know how to re-write it to vb. i get syntax errors on "base" when i try. what is it called with vb syntax?


Hi Lycken,

For example,

C# code

protected override void OnPreRender(EventArgs e)
{
// add base.OnPreRender(e); at the beginning of the method.
base.OnPreRender(e);

// codes to handle with your controls.
...
}

Convert to VB Code,

Protected Overloads Overrides Sub OnPreRender(ByVal e As EventArgs) ' add base.OnPreRender(e); at the beginning of the method. MyBase.OnPreRender(e) ' codes to handle with your controls.

End Sub

Here is anuseful tool.

I hope this help.

Best regards,

Jonathan


thanks a lot! it's working fine now - or at least this part of the solution is... i have a couple of other things that aren't doing so well at the moment, but i'll work on those for yet a while before i post here.

again, thanks!

Monday, March 26, 2012

Expression Web

Is there a way to get Expression Web to recognize the Ajax Toolkit Controls? I downloaded the toolkit but I do not know how to get the Ajax controls to show up in the Toolbox.

Hi Dlcahall,

If you are failed to add Ajax Control Toolkit to the Toolbox directly, you should add it like add a customer control.

Here is the steps.

1. Firstly you need to GAC the assembly

2. Next add a <%@.Register%> page directive to your page with the assemblies fully qualified name. If you don't add the page directive with a fully qualified name, then you lose design-time view of the control and intellisense.An alternative, and probably better, step is to add a web.config file to your project. Again you need a fully qualified name here.

For more details , please visithere.

Hope this helps.

Best regards,

Jonathan


I had already tried that and it did not work. I got an error, something about not having a unique ID or something. I do not remember. Also am noticing that Expression Web does not allow you to do code behind. Expression Web is a fine tool for straight forward stuff but it is doing to need another round before it becomes a full fledged .NET development tool. Maybe MS is not going to do that.


Hi Dlcahall,

I think in your situation,VS or Visual Studio Express is a better choice.

I hope this help.

Best regards,

Jonathan

Explaining the structure of Rating/Accordian Control

Are there any documentation or could anyonoe take the time to explain/document, or a step by step run through of creating controls similar to these two? Where the extender is 'dynamically' attached to a server control in the code?

Thanks and Regards.

Hi Inventisity,

Accordion,NoBot,Rating, andReorderList are all examples of controls that wrap extenders. This pattern is useful in situations where the extender requires the markup of the target control to be in a specific (and possibly lengthy) format. You write the server-side extender and client-side behavior as usual. You then create a control (by inheriting from something likeWebControl orPanel) that renders the appropriately formatted markup, dynamically create your extender/properties, and point yourproperties.TargetControlID atthis.ID (and hence the rendered markup). Following common practices for writing server controls, the extender and its properties are created in theCreateChildControls method (which we make sure is called before anywhere we access the extender/properties usingEnsureChildControls). Finally, the necessary properties are exposed on the control (and just passed off to the actual properties object).

I think this should give you an idea of what these controls are doing, but please post back if you have any other unanswered questions. If you plan on writing your own control that wraps extenders, keep an eye onwork item #1687 because it applies to all of these controls.

Thanks,
Ted

Expand/Collapse a group of CollapsiblePanelExtenders

I have a page with a group of CollapsiblePanelExtender controls I want to write a javascript function to expand or collapse all panels together at the same time. Is this possible and please how?

Thanks in advance

You can put your group of CollapsiblePanelExtender inside adiv/paneland have the collapse/expand controlid use thediv/panel.Its like a nested CollapsiblePanelExtender .


Hi Jessy ,

I have convered the EXACT SAME scenario on my blog over as an example of :

How to : Perform Operations on all instances of a Ajax Control Extender on a page

Hope this helps


Thanks Phanatic this is exactly what I need

Execute UpdateProgress after page load

I have UpdatePanel, Grid and UpdateProgress controls, all working together using Ajax. When user does any action with the grid, Updateprogress shows nice animated gif "Loading adata...".

However, when the page loads, it takes 5 minutes to load data to the grid. There is no message, nothing, so the user may think he has Internet connection problems... How can I make Updateprogres to show the animated gif, when the page is initially loading data to the grid?

I was thinking maybe there is some event after the page loads, in this case I could load the data, after the page loads... Is it possible? What is the standard way to do it? Thanks

Hi rfurdzik,

When you want to have influence in the partial rendering of your page take a look at this:

http://ajax.asp.net/docs/overview/PageRequestManagerOverview.aspx

The PageRequestManager is the place to be to customize your partial rendering.

Regards,


In your case i would suggest to take a look at the: PageLoading event

"The pageLoading event is raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. You can use this event to provide a custom transition effect for updated content."

Regards,


Hi I am not sure if that is what I need, I looked briefly at the link you gave me, but it seemsit points to PostBacks... I have no postback, this is the first time grid is loading. No user interaction occured yet, no postbacks. With postback works fine, just the initial load of data to the grid needs animation.

I am little bit lost in the info you gave me, would you guide me what event needs to be coded exactly and how to show the animation (I placed it in ProgressPanel)? Here is my scenario:

1) Page Loads

2) Animation shows "Loading data", grid is not visible yet

3) Data is loaded to the grid

4) Animation disappears

As I said earlier this is the initial load, first visit to the page, no postback yet...


There are two solutions:

The first you hide the gridview till the page completely loads and show only a progress image as shown below:

--------

<%@. 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>Sales Details</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div id="Progress"><img alt="Loading..." src="indicator.gif" /> Loading... </div>
<div id="GridContainer" style="display:none">
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString%>" SelectCommand="SELECT TOP (10000) SalesOrderID, SalesOrderDetailID, CarrierTrackingNumber, OrderQty, ProductID, SpecialOfferID, UnitPrice, UnitPriceDiscount, LineTotal, rowguid, ModifiedDate FROM Sales.SalesOrderDetail"></asp:SqlDataSource>
</div>
</form>
<script type="text/javascript">
Sys.Application.add_init(function() {
$get("GridContainer").style.display = "";
$get("Progress").style.display = "none";
});
</script>
</body>
</html>

----------

The second solution is to induce a postback in load. In the sample below it is done by using a Timer control in the UpdatePanel. The GridView is not set to visible when the Page is not in PostBack and as soon as the timer starts a postback is done causing a partial page update which eventually causes UpdateProgress to be shown:

<%@. Page Language="C#" AutoEventWireup="true" %><script runat="server"> protected void Page_Load(object sender, EventArgs e) { GridView1.Visible = IsPostBack; Timer1.Enabled = !IsPostBack; }</script><!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>Sales Details</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdateProgress ID="Progress" runat="server"> <ProgressTemplate> <div> <img alt="Loading..." src="indicator.gif" />Loading...</div> </ProgressTemplate> </asp:UpdateProgress> <asp:UpdatePanel ID="GridContainer" runat="server"> <ContentTemplate> <div id="Div1"> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString%>" SelectCommand="SELECT TOP (10000) SalesOrderID, SalesOrderDetailID, CarrierTrackingNumber, OrderQty, ProductID, SpecialOfferID, UnitPrice, UnitPriceDiscount, LineTotal, rowguid, ModifiedDate FROM Sales.SalesOrderDetail"> </asp:SqlDataSource> </div> <asp:Timer ID="Timer1" runat="server" Interval="100"> </asp:Timer> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> </asp:UpdatePanel> </form></body></html>


I think what youare reffering to is custom transition effect after postback. I have this functionality already done using Update panel and UpdateProgress controls. It all works.

What I need is to have the animation (under UpdateProgress) to be displayed during the INITIAL load of the page.

I was thinking maube no Ajax is needed in this case, maybe this can handled by standard ASP.NET code. Something like this (I am not sure what exactly events are):

1) Page load event - display animation (visble property = true), make grid invisible

2) Page loaded (?) - load data, (make grid visible, hide animation)

3) Postback - since I am changing the code now, not sure how the existing Ajax controls will behave (UpdatePanel + UpdateProgress...)


Hi rfurdzik,

Sorry that i didn't understand your question right. The option here above could give you a solution.

Regards,


yes, yes, your code makes sense. Thanks a lot!!! At least you understood what I need!

Dear Rama,

I like the second solution, it is very elegant. I do not fully understand the first one, but it is OK. I think your second solution needs to be modified in my case little bit. I am thinking to do this:

protected void Page_Load(object sender, EventArgs e)
{

if (IsPostback) {

LoadGridData();

}

GridView1.Visible = IsPostBack;

Timer1.Enabled = !IsPostBack;
}

As you see I have added additional if statement for loading the data to the grid, as showing the grid is not enough. Maybe that is why I was confused by the first example... Because I was thinking that even if youhide the grid,data load will occur, which will slow down my page load anyway... Maybe there is something I do not understand there...

However second solution seems will work for me...

Do you guys have some librarries with code? How do you find this? Do you organize your favorities in IE? That new IE is killing me, in version 7 it is so difficult to browse/bookmark anything if you have so many favorities. the reason is that it is all expended by deafault...


Oh, it is OK, your intention is the most important. You wanted to help! I may have not communicated well what I needed:) Thanks anyway for great info.

I have realized that the proposed second solution may also need to be changed more. This is the code I have in Page_Load:

if ((!Page.IsPostBack))

{

LoadData(15);

ViewState[

"CurrentTab"] ="0";// display the grid

}

As you can see I already check for Postback, I only load the data when it is first time load. This is of course for optimization purpose.

So now if I add timer code, we want the load of data to occur in THE FIRST POSTBACK ONLY. Not the first time the form is loading, but the first time postback is generated (by timer control). How would I acomplish this? I was thinking maybe setup a flag? I try this code, but it does not complie (I think some C# syntax issues, I am new to C#:))

m_DataLoaded = ((

Boolean)Session["m_DataLoaded"])=null ?true :false;

if ((Page.IsPostBack) & !(m_DataLoaded))

{

LoadData(15);

ViewState[

"CurrentTab"] ="0";

m_DataLoaded =

true;// display the grid

}

Session[

"m_DataLoaded"] = m_DataLoaded;

grdMyGrid.Visible = IsPostBack;

Timer1.Enabled = !IsPostBack;

What is wrong here? Something with casting I think... Please help.


Hirfurdzik ,

I used SqlDataSource control to bind to the grid which automatically binds the data provided the Grid is visible. So no penalty will be incurred.


Yes, I understand now. I can't figure this out what is wrong with my code, it compiles now, but getting error: m_DataLoaded = ((Boolean)Session["m_DataLoaded"])==null ? true : false; if ((Page.IsPostBack) & !(m_DataLoaded)) { LoadData(15); ViewState["CurrentTab"] = "0"; m_DataLoaded = true; // display the grid } Session["m_DataLoaded"] = m_DataLoaded; grdMyGrid.Visible = IsPostBack; Timer1.Enabled = !IsPostBack;This is the error:Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error: Line 96: m_dvInv = (DataView)(Session["m_dvInv"]);Line 97: Line 98: m_DataLoaded = ((Boolean)Session["m_DataLoaded"])==null ? true : false;Line 99: Line 100: if ((Page.IsPostBack) & !(m_DataLoaded))

Just changed editor back, beacuse the other one does not format. This one has some delay when typing, so many misstakes...

Yes, I understand now. I can't figure this out what is wrong with my code, it compiles now, but getting error:

m_DataLoaded = ((Boolean)Session["m_DataLoaded"])==null ? true : false;

if ((Page.IsPostBack) & !(m_DataLoaded))
{
LoadData(15);
ViewState["CurrentTab"] = "0";

m_DataLoaded = true;
// display the grid
}

Session["m_DataLoaded"] = m_DataLoaded;

grdMyGrid.Visible = IsPostBack;
Timer1.Enabled = !IsPostBack;


This is the error:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 96: m_dvInv = (DataView)(Session["m_dvInv"]);
Line 97:
Line 98: m_DataLoaded = ((Boolean)Session["m_DataLoaded"])==null ? true : false;
Line 99:
Line 100: if ((Page.IsPostBack) & !(m_DataLoaded))



m_DataLoaded = ((Boolean)Session["m_DataLoaded"])==null ? true : false;

should be

m_DataLoaded = Session["m_DataLoaded"] ==null ? true : false


Thank you Rama Khrishna, it compiles fine and runs fine now. However the grid is not visible. So eighter the timer did not start, or something wrong with the logic. I will debug it now...

Saturday, March 24, 2012

Exclude server controls in an UpadatePanel

Is there a way to exclude server controls that are surrounded by an UpdatePanel?

hello.

what do you meanu by exclude? if you're speaking about not generating html, then just set the enabled property to false...


I have two export buttons inside my usercontrol and said usercontrol is inside an UpdatePanel. I cannot change that it is inside an UpdatePanel, so I cannot just take them out of the UpdatePanel. I want them to generate, I just was wondering if there is a way to exclude them from the UpdatePanel that is surrounding the whole UserControl.

hello.

how about using an udpatepanel inside your user control that delimits all the controls (excluding the buttons)?


Hello, I have the same problem:

I use a GridView inside an UpdatePanel, every row has a 'print' button that generates a RTF document using the server side command 'Response.BinaryWrite'.

The button is generated inside the GridView using a template element, if the gridview is inside the updatepanel the action fails, if the grid is outside the updatepanel the action succeed

How can I exclude the print buttons from the UpdatePanel leaving the other columns updatable?

matteo conta



I have found a solution, not very clean but working:
My problem is how to download a RTF on the browser using a button inside an UpdatePanel, in my case a button inside a GridView:

Insert in the update panel a hidden iframe with runat=server

<atlas:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<iframe id="frameGenerateRTF" runat=server src="http://pics.10026.com/?src=about:blank" width=0 height=0></iframe>
... GridView code....

On theGridView1_RowCommand that generates the RTF export change the src of the IFRAME pointing to the page that generates the binary export

frameGenerateRTF.Attributes.Add("src","Export.aspx?ACTION=PRINT&IDDOCUMENT=12345");

The Export.aspx page uses the Response.BinaryWrite and Response.End() to write a stream (PDF,RTF etc..) to the browser.

You can't use the Response.Redirect on the same page because when you write the binary stream you interrupt the processing on the page usig Response.End() and the atlas page end to respond.

Hope to be usefull
Matteo Conta


I will check it out. Thanks for the help.

How about this:

1a) Set UpdatePanel.ChildrenAsTriggers = false, it is true by default.http://ajax.asp.net/docs/mref/0b850465-67ca-2600-9fdc-2c16d689ab89.aspx
1b) Then any controls inside the UpdatePanel you do want to trigger a refresh, you can set a trigger for.http://ajax.asp.net/docs/tutorials/enhancing/declareTriggers.aspx. (You can set a control like GridView as an async trigger and then all postbacks originating from inside it will be treated as async postback.)

another option

2) Set the control inside the UpdatePanel as a PostBack trigger, i.e. it causes a full page refresh.
<Triggers>
<asp:PostBackTrigger ControlID="YourControlID"/>
</Triggers>

The second option may not be exactly what you are looking for but thought I'd mention it.


hello.

not sure but what i think he wants is to define a zone inside the panel which doesn't get updated...


Oh, if that's the case, I don't know of any easy way to do that. Probably should start by removing the UpdatePanel that wraps everything (including the piece that you dont' want updated) and then add sibling UpdatePanels on the page with UpdateMode=Always.

Thanks marcgel, that helped me alot!

Pat


marcgel:

Oh, if that's the case, I don't know of any easy way to do that. Probably should start by removing the UpdatePanel that wraps everything (including the piece that you dont' want updated) and then add sibling UpdatePanels on the page with UpdateMode=Always.

What is the meaning of "sibling UpdatePanel on the page"? Can you please make it more clear?

Eriawan.

Exception: Extender controls may not be registered after PreRender

Hello,

I'm dynamically adding UserControls and Extenders for those Controls to my website.
After a postback I get this exception:

"Extender controls may not be registered after PreRender."

What is the (general) problem with that?

Thanks a lot!
Heinz

I am getting the same error message trying to add a UserControl with a SliderExtender on it. This seems like it should be a common problem. I can′t find any general answers for this one, did you find a solution for it Billy_Joe?
This sounds like an issue with ASP.NET AJAX rather than something specific to the Toolkit. Have you searched the ASP.NET AJAX forums?

Hi

Im also getting the "Extender controls may not be registered before PreRender." error and was wondering if anyone found any answers. Im trying to combine a textbox and CalendarExtender together and then use it in another server control. Ive tried to use this control straight on to a page as well and it still fails. The page contains a ScriptManager and an Update panel. Im using the 1.0.10201.0 of the AjaxToolKit. Any response is appriciated.

This is my code so far:

public class CustomDateControl : Control, INamingContainer
{
private TextBox dateTextBox = new TextBox();
private CalendarExtender ajaxCalenderExtender = new CalendarExtender();

public CustomDateControl()
{
}

public string Value
{
get
{
this.EnsureChildControls();
return this.dateTextBox.Text;
}
set
{
this.EnsureChildControls();
this.dateTextBox.Text = value;
}
}

protected override void OnInit(EventArgs e)
{
ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
if (scriptManager != null)
{
scriptManager.RegisterExtenderControl<CalendarExtender>(ajaxCalenderExtender, dateTextBox);
}
base.OnInit(e);
}


protected override void CreateChildControls()
{
this.dateTextBox.ID = "dateTextBox";
this.Controls.Add(dateTextBox);
this.ajaxCalenderExtender.ID = "calendarExtender";
this.ajaxCalenderExtender.TargetControlID = dateTextBox.ID;
this.ajaxCalenderExtender.Page = this.Page;
this.Controls.Add(ajaxCalenderExtender);
base.CreateChildControls();
}
}


Hi, did anyone here ever come up with an answer for this? I'm pretty stumped. I'm dynamically adding a ModelPopupExtender to my page; on the first load of the page it works fine, but on any postback it is throwing this error.

Thanks.


This problem has to do with the lifecycle of the webpart (server control) with respect to extender controls such as the ajaxcontrol toolkit.

I've once called MS support on this and was told that AJAX ControlToolkit is not supported , only AJAX.NET Extensions which means the updatepanel and scriptmanager.

It should work, i stuck a scriptmanager on a masterpage of an asp.net web site and the server control (webpart ) worked. I even used the ajax.net extensions tabcontainer and tabcontrols. Once the scriptmanager is on the page before the webpart it should work


Here's what I did to get around it:

At first, I was saving the dynamically added custom controls to a Session variable, pulling them back out as the page reloaded in order to rebuild the Control Tree. (Actually, I was saving the controls in a List<> collection, then saving that list in the session... running a foreach to pull them back out in the page_load event. To add to the complication, the custom controls was really a panel with several labels, text boxes, and AJAX extenders built into it.)

Well, a bit of research shows that controls, even custom controls, can not be re-used directly. It looks like the AJAX extenders are complaining that they had already been pre-rendered because theywere pre-rendered the last time they were put on the page, so obviously they can't be pre-rendered again. (This was a big DUH moment for me.)

So, instead of putting the controls back on the page, I wrote a quick and dirty function... It takes the old custom control as an argument and returns a brand new custom control with the same values...

private CustomPanel RefreshPanel(CustomerPanel oldPanel)
{
CustomPanel newPanel =new CustomPanel();
newPanel.value1 = oldPanel.value1;
// etc...
return newPanel;
}

// and in the Page_Load...

foreach (CustomPanel oldPanelin Session["SavedPanelsList"])
{
updatePanel.ContentTemplateContainer.Controls.Add(RefreshPanel(oldPanel));
}

Yes, it is dirty... It works for now, though, and with a deadline looming, I'm just glad that there will be time to refactor later.

I hope this helps someone get unstuck.

And, of course, the best solution remains to pre-define the controls into the form first, and set them to be visible = false by default. If you're working with 0 to 20+ of these controls, though, it might be best to do things the hard way and mess with the dynamic controls.