Showing posts with label load. Show all posts
Showing posts with label load. Show all posts

Wednesday, March 28, 2012

Accordian - Dynamic addition/subtraction of panels?

I want to create an accordian at page load and dynamically add a number of panels with varying content at that time..any thoughts and optimally psuedocode on how to do this?Hi Mike,

You can do it just like other controls. Here's a small example:

<%@. Page Language="C#" %><%@. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="atlasToolkit" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> /// <summary> /// Dynamically create our accordion panes /// </summary> protected override void OnLoad(EventArgs e) { base.OnLoad(e); AccordionPane pane1 = new AccordionPane(); pane1.HeaderContainer.Controls.Add(new LiteralControl("Pane 1")); pane1.ContentContainer.Controls.Add(new LiteralControl("Pane 2")); MyAccordion.Controls.Add(pane1); AccordionPane pane2 = new AccordionPane(); pane2.HeaderContainer.Controls.Add(new LiteralControl("Pane 2")); pane2.ContentContainer.Controls.Add(new LiteralControl("Content 2")); MyAccordion.Controls.Add(pane2); }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Accordion Demo</title> <style> .accordionHeader { border: 1px solid #2F4F4F; color: white; background-color: #2E4d7B; font-family: Arial, Sans-Serif; font-size: 12px; font-weight: bold; padding: 5px; margin-top: 5px; cursor: pointer; } .accordionContent { background-color: #D3DEEF; border: 1px dashed #2F4F4F; border-top: none; padding: 5px; padding-top: 10px; } </style></head><body><form runat="server"><div> <atlas:ScriptManager ID="Scripts" runat="server" /> <atlasToolkit:Accordion ID="MyAccordion" runat="server" SelectedIndex="0" HeaderCssClass="accordionHeader" ContentCssClass="accordionContent" FadeTransitions="true" FramesPerSecond="40" TransitionDuration="250" AutoSize="None"> </atlasToolkit:Accordion></div></form></body></html>
Thanks,
Ted

I think the code to add AccordinePane to Accordin is changed. the previous code didnt work for me.

// import Atlas Controlkit.

using System.Web.UI.HtmlControls;
using AtlasControlToolkit;

//Create a Atlas Accordion instance.
Accordion aAccord = new Accordion();


// Create AccordionPane instance.

AccordionPane accordPane = new AccordionPane();

// create your Header panel( the title of each Pane). and your component to each pane container.
// add Header Panel and Container panel, the panel which which will collape and open.

accordPane.HeaderContainer.Controls.Add( headerPanel );
accordPane.ContentContainer.Controls.Add( collapsePanel );

// add accordPane to Accordin instance.
aAccord.Panes.Add(accordPane);


// you can add as many AccordPanes as you want.


// Add Accordin object to the Panel.
myPanel.Controls.Add( aAccord );

Kishore.


Hi Kishore,

Yes - in response to user feedback we've hidden theControls collection and replaced it with the easier to useAccordionPane-onlyPanes collection.

Thanks,
Ted

Is there a way to add an unknown number of AccordionPanes? I'm trying to do thing:

List<string> addresses =newList<string>();
addresses.Add("123 Main St, Phoenix, AZ, 85041");
addresses.Add("658 Alta Vista Rd, Phoenix, AZ, 85041");int name =1;
foreach (string sin addresses)
{
AccordionPane pane =newAccordionPane();
pane.HeaderContainer.Controls.Add(newLiteralControl(s));

pane.Width =

300;
pane.ID ="pane" + name;
Accordion1.Controls.Add(pane);//it doesn't add the right pane because it's named wrong. What should I change?
name++;
}

Thanks!


And I can add the code in VB:

This is in AJAX.aspx (for example):

<ajaxToolkit:AccordionID="aDynamicky"runat="server">

<Panes>

</Panes>

</

ajaxToolkit:Accordion>

And following is in code behind AJAX.aspx.vb:

Imports AjaxControlToolkit

Partial

Class AJAXInherits System.Web.UI.PageProtectedSub aDynamicky_PreRender(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles aDynamicky.PreRenderDim panel1As AccordionPane =New AccordionPane

panel1.HeaderContainer.Controls.Add(

New LiteralControl("This is a header of 01."))

panel1.ContentContainer.Controls.Add(

New LiteralControl("And here is the content of 01."))

aDynamicky.Panes.Add(panel1)

Dim panel2As AccordionPane =New AccordionPane

panel2.HeaderContainer.Controls.Add(

New LiteralControl("This is a header of 02."))

panel2.ContentContainer.Controls.Add(

New LiteralControl("And here is the content of 02."))

aDynamicky.Panes.Add(panel2)

EndSub

End

Class

Of course, you can format your panels via CSS.

Saturday, March 24, 2012

About CollapsiblePanelExtender

Hi friends...

I have a CPE; it will load collapsed; and when extended some of the contents will change...

is it possible??

Thanks...

everything is possible =)


:) thanks but how? :D

Wednesday, March 21, 2012

A problem when I use script manager, script manager proxy

I have an default.aspx and 3 link in that page. When I click to one of these links I want to load a usercontrol( ex: control1.ascx ) and in this user control I also use ajax in this control. Other Developer said that I must use a master page and declare a script manager in this page. In usercontrol I just need to use scriptmanagerproxy... But I don't know exactly what I have to do. Can you help me. Thanks all of you a lot.

Hi hamanhtuan,

Well the scriptmanagerproxy is an extended version of the scriptmanager. In your situation i think you can fix it with just a scriptmanager on your .aspx page and no scriptmanagerproxy on the user control. When your webpage contains a scriptmanager control and the usercontrol isn't you can still make use of the Ajax functionalities. keep in mind that when you deploy this usercontrol on an apsx page where you're not have a scriptmanager then it isn't working. The scriptmanagerproxy isn't a solution for this problem because the scriptmanagerproxy also needs a scriptmanager control. So drop a scriptmanager on your aspx page and other controls (Updatepanels) in your usercontrol and it will work. Hope it helps.

Regards


When I remove a scriptmanagerproxy on my controls and use Updatepanels in my usercontrol then my *.aspx can load these control. But in my control, I have a gridview, a refresh button and I want to auto update this gridview when click this button. How can I do this work ? Thank you for your last answer.

Hi hamanhtuan,

SO your gridview needs to be in the updatepanel and the button should be the trigger for the updatepanel. this will partial update the controls inside the update panel but take a look at the following:

Controls that Are Not Compatible with UpdatePanel Controls

The following ASP.NET controls are not compatible with partial-page updates, and are therefore not supported inside anUpdatePanel control:

TreeView andMenu controls.


Thank you for your answers.