Showing posts with label masterpage. Show all posts
Showing posts with label masterpage. Show all posts

Wednesday, March 28, 2012

Very simple example... with masterpage!

I create a really simple example using atlas on a masterpage.

Ihave this code:

<

cc1:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"></cc1:ScriptManager><cc1:UpdatePanelID="up2"runat="server"><ContentTemplate><asp:Labelid="lbl1"runat="server"Text="Label"></asp:Label><BR/><asp:LinkButtonid="LinkButton1"runat="server"OnClick="LinkButton1_Click">LinkButton</asp:LinkButton></ContentTemplate>

</cc1:UpdatePanel>

and this:

protectedvoid LinkButton1_Click(object sender,EventArgs e)

{

lbl1.Text =

"egege";

}

the problem is that the event is raised, lbl1.Text became "egege", but the text of the label on the page it is still the same...

what can be wrong?

Can you supply a bit more code and perhaps explain how the cc1 namespace prefix got placed in front of your atlas controls?

<cc1:ScriptManager......

Instead of

<atlas:ScriptManager....

Etc.

I'm not saying that's the problem, but I'm unfamiliar with how that prefix got there.


hello.

btw, you should also start by using fiddler to see the msg that the client is receiving from the server...is there any forbidden xml chars on the head section?


Eureka!

The problem was that there was a<script language="Javascript"> block on the head of my masterpage.

I canceled it and everythigs works!

Can anybody tell me why?


hello.

well, currently, atlas packages the content of the head element in the msg that is sent from the server in response to a partial postback. since it doesn't escape those elements (say, by using a cdata section), you can't have any forbidden xml chars there (and it's really easy to get one of those inside a javascript script - for instance, this would make your document not well formed: for( ; i < 10; i++ ))

in the current version of atlas, when the returned xml document isn't well formed, the client platform discards it without giving any feedback.

Saturday, March 24, 2012

Way to hold state of collapsible panel?

I've created a website application with a MasterPage that has an Accordion side-menu contained in a Collapsible Panel. It works fine, however, I need a way to hold the state of these controls when the user is redirected to another page.

So, if they have the side-menu collapsed and click a link to another page, when the new page is displayed, the side-menu should remained collapsed...is there anyway to do this? Basically, I just need to set some Session Variables to hold the state whenever the user manipulates the side-menu...

You could probably do it in viewstate? I don't have time to test it out right now, I'll try to get back to this later if nobody else has answered. Basically after you open a collapsible panel you could set something like viewstate("thiscontrolisCollapsed")=false and then on the page load you could do something like

if viewstate("isCollapsed")=false then

' code to open panel

end if

just off the top of my head. Sorry I can't be more technical with it, I'm getting ready to walk out the door and thought I'd throw this out as a suggestion.


Thanks, but the problem is actually being able to hold the state of the collapsible panel on the server side. All the collapsing and expanding is handled in client side javascript, and I'd need to somehow run some server-side code to hold the state after the client script has expanded or collapsed the panel.

I was thinking I need to fire off a client side call-back, but I can't figure out how to trigger it when the collapsible panel is expanded or collapsed...


Ok, I've figured out how to accomplish this. I already had an image that was the ExpandControlID and CollapseControlID, that the user clicks on to expand or collapse the panel. So I simply added an onclick attribute to that image which calls a javascript that initiates a client side call-back, where I pass the Collapsed status of the panel to the server and set a session variable. My code is below:

<script type="text/javascript" >
function holdSideMenuState(){
holdSideMenuStateInSession(!$find("SideMenuBehavior").get_Collapsed());
}

function sessionNowHoldsSideMenuState(isSideMenuCollapsed, context){
alert(isSideMenuCollapsed);
}
</script>
<table border="0" cellpadding="0" cellspacing="0" class="SideMenu">
<tr>
<td class="SideMenuExpandCollapse" valign="top">
<asp:Image ID="imgExpandCollapse" runat="Server" ImageUrl="~/images/collapse.jpg" CssClass="ExpandCollapseImage" />
</td>
<td>
<asp:Panel ID="pnlSideMenu" runat="Server">
Side Menu Content goes here....
</asp:Panel>
</td>
</tr>
</table
<ajaxToolkit:CollapsiblePanelExtender ID="cpeSideMenu" runat="server"
TargetControlID="pnlSideMenu"
CollapsedSize="0"
Collapsed="False"
ExpandControlID="imgExpandCollapse"
CollapseControlID="imgExpandCollapse"
AutoCollapse="False"
AutoExpand="False"
ScrollContents="False"
ImageControlID="imgExpandCollapse"
ExpandedImage="~/images/collapse.jpg"
CollapsedImage="~/images/expand.jpg"
ExpandDirection="Horizontal"
BehaviorID="SideMenuBehavior">
</ajaxToolkit:CollapsiblePanelExtender>


protected void Page_Load(object sender, EventArgs e)
{
string callBackReference = Page.ClientScript.GetCallbackEventReference(this,"isSideMenuCollapsed","sessionNowHoldsSideMenuState","context");
string callBackScript ="function holdSideMenuStateInSession(isSideMenuCollapsed, context){" + callBackReference +"}";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"holdSideMenuStateInSession", callBackScript,true);

imgExpandCollapse.Attributes["onclick"] +="holdSideMenuState();";

if (!IsPostBack)
{
if (Session["IsSideMenuCollapsed"] ==null) Session["IsSideMenuCollapsed"] =false;

cpeMenu.Collapsed = Convert.ToBoolean(Session["IsSideMenuCollapsed"]);
}
}

public void RaiseCallbackEvent(string isSideMenuCollapsed)
{
Session["IsSideMenuCollapsed"] = isSideMenuCollapsed;
}

public string GetCallbackResult()
{
return Session["IsSideMenuCollapsed"].ToString();
}


I have some more work to do because in my real code, I actually have an Accordion inside the collapsible panel, and I need to hold the state of the accordion as well, but I'll save any questions I have with that for another thread...

Wednesday, March 21, 2012

Web Part Verb Menus inside UpdatePanel...

I have 6 webparts inside UpdatePanels on my masterpage. The contents of all of the webparts are usercontrol.ascx's.

One of which is only moveable, the others are moveable, closeable, and minimizeable. There are 3 on the left side, and 3 on the right side. All 6 webzone's contents are dragable etc, and work perfectly. My problem is that the three webzones on the right work fine with regards to close, minimize/restore. As for the 2 on the left, only one will work, then the verb menu for the other one won't work anymore untill a new page load. If you choose WebZone2 to close/minimize, then WebZone3's verb menu will fail to load. The small triangle is there, but no menu drops when it is clicked on. If you choose WebZone3 to minimize, then WebZone2 won't work properly.

All the webzones look like...

Not sure why, the zones on the right don't work properly.

<

atlas:UpdatePanelID="wbpz6"runat="server"><ContentTemplate><asp:WebPartZoneID="WBPZNews"runat="server"BorderColor="#CCCCCC"Font-Names="Verdana"Padding="6"Width="120px"><PartChromeStyleBackColor="#F7F6F3"BorderColor="#E2DED6"Font-Names="Verdana"ForeColor="White"/><MenuLabelHoverStyleForeColor="#E2DED6"/><EmptyZoneTextStyleFont-Size="0.8em"/><MenuLabelStyleForeColor="White"/><MenuVerbHoverStyleBackColor="#F7F6F3"BorderColor="#CCCCCC"BorderStyle="Solid"BorderWidth="1px"ForeColor="#333333"/><HeaderStyleFont-Size="0.7em"ForeColor="#CCCCCC"HorizontalAlign="Center"/><MenuVerbStyleBorderColor="#232323"BorderStyle="Solid"BorderWidth="1px"ForeColor="White"/><PartStyleFont-Size="0.8em"ForeColor="#333333"/><TitleBarVerbStyleFont-Size="0.6em"Font-Underline="False"ForeColor="White"/><MenuPopupStyleBackColor="#232323"BorderColor="#CCCCCC"BorderWidth="1px"Font-Names="Verdana"Font-Size="0.6em"/><PartTitleStyleBackColor="#232323"Font-Bold="True"Font-Size="0.8em"ForeColor="White"/><ConnectVerbVisible="False"/><ExportVerbVisible="False"/><HelpVerbVisible="False"/><EditVerbVisible="False"/><ZoneTemplate><uc5:AFCSNewsID="News1"runat="server"></uc5:News></ZoneTemplate></asp:WebPartZone></ContentTemplate></atlas:UpdatePanel>

Thanks,

Ted

I just posted with a similar problem. Did you ever resolve this?

Nope, some of my webparts have this problem, and some of them don't. Never have figured this out.

Texx


Thanks. I'm hoping that now, since we can dynamically add update panels (as of the June CTP) that maybe it might avoid the problem. But we haven't gone down that road yet...