ラベル resize の投稿を表示しています。 すべての投稿を表示
ラベル resize の投稿を表示しています。 すべての投稿を表示

2012年3月28日水曜日

ResizableControlExtender does not resize image??

hi,

guys

ResizableControlExtender control does not resize the image.does this control not support the image control?

guide me.

thanks in advance.

Miss Sheetal,

Put your image control inside a panel and set the TargetControlID of ResizableControlExtender to the Panel's ID.


I've tried as u said,but it resizes panel not image!!!!!!!!! just check out this code:

<asp:Panel ID="panel1" BorderColor="black" BorderWidth="5" runat="server" Height="200">
<img id="img1" src="http://pics.10026.com/?src=images/untitled5.bmp" alt="sd" runat="server" />
</asp:Panel
<cc1:ResizableControlExtender ID="resiable" HandleCssClass="handleText" ResizableCssClass="resizingImage" HandleOffsetX="10" HandleOffsetY="20" runat="server" TargetControlID="panel1"></cc1:ResizableControlExtender>

<Script language="text/javascript">

.handleText
{
width:16px;
height:16px;
background-image:url(images/HandleGrip.png);
overflow:hidden;
cursor:se-resize;
}

.resizingImage
{
padding:0px;
border-style:solid;
border-width:3px;
border-color:#B4D35D;
}

</Script>


You have not specified the Client Side Javascripts that will actually resize the image. Watch thetutorial video on how to do that.


Thanks Buddy!!!!!!!!!!!!!

It Really helps me. Thanx for immediate reply.


Then please mark my previous post as the answer.

ResizableControlExtender

I cannot get the ResizableControlExtender to work on a textbox multiline.
any help.........

I have also tried to put the text box in a panel & resize the panel. Only the panel resizes not the textbox

Hi U2envy1,

There's a wonderful sample contained in Ajax Control Toolkit. Here is the code section.

<asp:Panel ID="PanelText" runat="server" CssClass="frameText">
This text resizes itself to be as large as possible within its container.
</asp:Panel>

<ajaxToolkit:ResizableControlExtender ID="ResizableControlExtender2" runat="server"
TargetControlID="PanelText"
ResizableCssClass="resizingText"
HandleCssClass="handleText"
MinimumWidth="100"
MinimumHeight="50"
MaximumWidth="400"
MaximumHeight="150"
OnClientResize="OnClientResizeText" />

function OnClientResizeText(sender, eventArgs) {
// This sample code isn't very efficient, but demonstrates the idea well enough
var e = sender.get_element();
// Make the font bigger until it's too big
while((e.scrollWidth <= e.clientWidth) || (e.scrollHeight <= e.clientHeight)) {
e.style.fontSize = (fontSize++)+'pt';
}
var lastScrollWidth = -1;
var lastScrollHeight = -1;
// Make the font smaller until it's not too big - or the last change had no effect
// (for Opera where e.clientWidth and e.scrollWidth don't behave correctly)
while (((e.clientWidth < e.scrollWidth) || (e.clientHeight < e.scrollHeight)) &&
((Sys.Browser.agent !== Sys.Browser.Opera) || (e.scrollWidth != lastScrollWidth) || (e.scrollHeight != lastScrollHeight))) {
lastScrollWidth = e.scrollWidth;
lastScrollHeight = e.scrollHeight;
e.style.fontSize = (fontSize--)+'pt';
}
}

There's a little difference to what your want.You can use $get("<%=Your TextBox.ClientID%>").style.width= value to change its width property.

For more details , please dip into the source code.

Best regards,

Jonathan


Thanks much appreciated.
How do I do this ?

You can use $get("<%=Your TextBox.ClientID%>").style.width= value to change its width property.


Hi U3envy1,

I have found another solution which is better than the former. It will change the TextBox's width sostenuto while the former solution only changes its width after the resize operation. In this solution, we attached a Javascript function to the ResizableControlExtender's add_resizing event. The function will resize the TextBox according to the Panel's width.

Here is the whole sample which you can copy into your project.

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title> <style> .handleText { width:16px; height:16px; background-image:url(images/HandleGrip.png); overflow:hidden; cursor:se-resize; } .resizingText { padding:0px; border-style:solid; border-width:2px; border-color:#7391BA; } .frameText { width:100px; height:100px; overflow:auto; float:left; background-color:#ffffff; border-style:solid; border-width:2px; border-color:Gray; font-family:Helvetica; line-height:normal; } </style> </head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Panel ID="Panel1" runat="server" CssClass="frameText"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </asp:Panel> <ajaxToolkit:ResizableControlExtender ID="ResizableControlExtender1" runat="server" TargetControlID="Panel1" BehaviorID="MyRCEBID" ResizableCssClass="resizingText" HandleCssClass="handleText" MinimumWidth="100" MinimumHeight="50" MaximumWidth="400" MaximumHeight="150" /> <script type="text/javascript" language="javascript"> var widht;function pageLoad(){ $find('MyRCEBID').add_resizing(onResizing); } function onResizing(){ width = $find('MyRCEBID').get_element().style.width; width = width.substring(0,width.length-2); width = width -10; width = width +'px'; $get("<%=TextBox1.ClientID%>").style.width = width; } </script> </form></body></html>

I really hope this help. Please pay special attention to the "Bold" Part.

Best regards,

Jonathan


Thanks much appreciated. I will try it soon. Just have so much to do at the moment. thanks again.


I had a chance to play with it. Its just what I wanted. Thanks its working beautifully.
How do I get the Textbox height to grow with the panel control?


Hi U2envy1,

$get("<%=TextBox1.ClientID%>").style.height = $find('MyRCEBID').get_element().style.height; Please have a try. By the way, you should modify the height property just like what we did on the width property.

Best regards,

Jonathan


Thanks once again.
One more thing about this. How do I get the font size to increase and decrease accordingly.


Hi U2envy1,

$get("<%=TextBox1.ClientID%>").style.fontSize = a certain value. Now , you should write your own arithmetic to work out value.

Best regards,

Jonathan


Hi,

I've done this and it works fine, except when I put it in a user control. When I do this, and use the resizable textbox more than once on the same page it gives me the error "Error: Sys.InvalidOperationException: Two components with the same id 'MyRCEBID' can't be added to the application".

So basically do I just need to change the "behaviorid" and the bit of javascript that references it to be something dynamically named? And if so, how might I go about this?

My code basically mirrors 'Jonathan Shen's' post


Hi Jonathan, I found code to work out the arithmetic value. how do I add this to the code you have provided already.

var fontSize = 12;

function OnClientResizeText(sender, eventArgs) {

// This sample code isn't very efficient, but demonstrates the idea well enough

var e = sender.get_element();

// Make the font bigger until it's too big

while((e.scrollWidth <= e.clientWidth) || (e.scrollHeight <= e.clientHeight)) {e.style.fontSize = (fontSize++)+'pt';

}

var lastScrollWidth = -1;

var lastScrollHeight = -1;

// Make the font smaller until it's not too big - or the last change had no effect

// (for Opera where e.clientWidth and e.scrollWidth don't behave correctly)

while (((e.clientWidth < e.scrollWidth) || (e.clientHeight < e.scrollHeight)) &&

((Sys.Browser.agent !== Sys.Browser.Opera) || (e.scrollWidth != lastScrollWidth) || (e.scrollHeight != lastScrollHeight))) {

lastScrollWidth = e.scrollWidth;

lastScrollHeight = e.scrollHeight;

e.style.fontSize = (fontSize--)+'pt';

}


Hi U2envy1,

I think you can add arithmetic code insideonResizing(){},sender.get_element() equal to $find('MyRCEBID').get_element(), you can replace it.

Hope this help.

Best regards,

Jonathan


I am lost when it comes to Java Script.
This is what I have so far. Any help on this. My font goes very small on resize thou. How do I increment it ?

var fontSize = 12;

function onResizing(){

width = $find('MyRCEBID').get_element().style.width;

width = width.substring(0,width.length-2);

width = width -10;

width = width +'px';height = $find('MyRCEBID').get_element().style.height;

height = height.substring(0,height.length-2);

height = height -10;

height = height +'px';

$get("<%=TextBox1.ClientID%>").style.width = width;

$get("<%=TextBox1.ClientID%>").style.height = height;

fontSize = $find('MyRCEBID').get_element().style.fontSize;fontSize = (fontSize++)+'pt';

$get("<%=TextBox1.ClientID%>").style.fontSize = fontSize;

}


Hi U2envy,

Here is the sample that I have expanded the reset text function.

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title> <style> .handleText { width:16px; height:16px; background-image:url(images/HandleGrip.png); overflow:hidden; cursor:se-resize; } .resizingText { padding:0px; border-style:solid; border-width:2px; border-color:#7391BA; } .frameText { width:100px; height:100px; overflow:auto; float:left; background-color:#ffffff; border-style:solid; border-width:2px; border-color:Gray; font-family:Helvetica; line-height:normal; } </style> </head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Panel ID="Panel1" runat="server" CssClass="frameText"> <asp:TextBox ID="TextBox1" runat="server" value="hello"></asp:TextBox> </asp:Panel> <ajaxToolkit:ResizableControlExtender ID="ResizableControlExtender1" runat="server" TargetControlID="Panel1" BehaviorID="MyRCEBID" ResizableCssClass="resizingText" HandleCssClass="handleText" MinimumWidth="100" MinimumHeight="50" MaximumWidth="400" MaximumHeight="150" /> <script type="text/javascript" language="javascript"> var widht; function pageLoad(){ $find('MyRCEBID').add_resizing(onResizing); } var fontSize = 12; function onResizing(){ width = $find('MyRCEBID').get_element().style.width; width = width.substring(0,width.length-2); width = width -10; width = width +'px'; $get("<%=TextBox1.ClientID%>").style.width = width; $get("<%=TextBox1.ClientID%>").style.height = $find('MyRCEBID').get_element().style.height; e = $get("<%=TextBox1.ClientID%>"); // Make the font bigger until it's too big while((e.scrollWidth <= e.clientWidth) || (e.scrollHeight <= e.clientHeight)) { e.style.fontSize = (fontSize++)+'pt'; } var lastScrollWidth = -1; var lastScrollHeight = -1; // Make the font smaller until it's not too big - or the last change had no effect // (for Opera where e.clientWidth and e.scrollWidth don't behave correctly) while (((e.clientWidth < e.scrollWidth) || (e.clientHeight < e.scrollHeight)) && ((Sys.Browser.agent !== Sys.Browser.Opera) || (e.scrollWidth != lastScrollWidth) || (e.scrollHeight != lastScrollHeight))) { lastScrollWidth = e.scrollWidth; lastScrollHeight = e.scrollHeight; e.style.fontSize = (fontSize--)+'pt'; } }form></body></html>

fontSize = $find('MyRCEBID').get_element().style.fontSize get the Panel's fontSize instead of the TextBox's.

I hope this help.

Best regards,

Jonathan


Thanks much appreciated. I wish to add this code to every app I build. Ill comment it with inspired by Jonathan.
Thanks again...... !!!

ResizableControlBehavior sizing to 0 in initialize, why?

This line is in the ResizableControlBehavior.initialize code:

this._resizeControl(0, 0, 0, 0);

Why? It makes me do fancy things in my resize handler to avoid this call, but I'm wondering if I'm missing some intended logic here.

Any thoughts on this? It breaks the resize control in IE for divs that use CSS to get width.
It sets up the internal state and fires the initial resizing event. Why is this a problem?
In IE with a textarea that is set to width: 100% in the CSS, this results in a 0 size text area.
Have you tried nesting the TEXTAREA in a DIV similar to how the sample page does with the image example (which has width=100%, height=100%)?

ResizableControlExtender: Allowing only horizontal resizing

Hi; I have a ResizableControlExtender control in my page and I'd like to be able to resize it only in x direction (unlike the one in this forum input text control)

Thanks

Any relations to this code peace?:

<scripttype="text/javascript">
function OnClientClickGrow () {
var rcp = $find('ResizableControlBehavior1');
var size = rcp.get_Size();
rcp.set_Size( { width: size.width*2, height: size.height*2 } );
returnfalse;
}
</script>

Just set the ResizableControlExtender's MinimumHeight and MaximumHeight to the same value.

Joe


:) I've found out but u were faster :)

Thanks...

MinimumHeight="500" MaximumHeight="500"

ResizableControlExtender resize the vertical (height) only. EASY ONE!

Hey.. I got an easy one for yall..

I am using the resizablecontrolextender for a panel control. I want the client to have the ablility to resize the height of the box but NOT the width.

This works in Firefox, but not in IE 7 .. anyone got an idea? NO WIDTH!!

"ResizableControlExtender1" runat="server" TargetControlID="thePanel" MinimumWidth="-1" MaximumWidth="-1" MaximumHeight="400" MinimumHeight="100" HandleCssClass="handle" ResizableCssClass="onresize" HandleOffsetX="-300" >

Set MaximumWidth=MinimumWidth=200px (or whatever).

David Anson:

Set MaximumWidth=MinimumWidth=200px (or whatever).

Thatdoes work, but I want my resizable panel inside a div that expandshorizontally (liquid) with the window. The Control itself can beexpanded by the browser window size. An example would be like howoutlook separates emails (in a grid) above, and email details below.You can change the vertical size of the two boxes, but not make themsmaller than the window.

Essentially, I need the equivalent of minimumwidth="100%"


Since I really really want to figure this out I am providing an example to see if I can explain this problem better.

Here is a simple code example to illustrate:

<body>
<form id="form1" runat="server">
<style type="text/css">

.handle { background:Black; width:20px; height:20px; }

</style>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div id="topDiv" runat="server" style="background:Blue; height:100px; display:block; width:100%;">
Content is in here.
</div
<div id="bottomDiv" runat="server" style="background:Red; height:200px;">
Some more content in here as well.
</div
<ajaxToolkit:ResizableControlExtender ID="extender" runat="server"
TargetControlID="topDiv"
HandleCssClass="handle"
MinimumHeight="100"
MaximumHeight="500">
</ajaxToolkit:ResizableControlExtender>

</form>
</body>
 
NOTICE: Both Divs expand to the size of the browser window. I just want to be able to resize the top Div without the ability to change the width. Ideas? Help! 

Since apparently this wasn't so easy I had to figure out a solution for myself. I thought I'd share:

<style type="text/css"> .topRow { overflow:hidden; display:block; background-color:#e6e6de; border:solid 1px black; } .innerTopRow { position:relative; top:0; left:0; right:0; bottom:0; height:93%; overflow:auto; } div.bottomRow { position:fixed; top:0px; bottom:0px; right:20px; left:212px; background:Green; overflow:auto; border:solid 1px black; } .handleTop { width:2000px; height:5px; background:#e6e6de; border-top:solid 1px black; border-bottom:solid 1px black; overflow:hidden; cursor:n-resize; } </style> <asp:ScriptManager ID="ScriptManager" runat="server" /> <asp:Panel id="topRowPanel" runat="server" CssClass="topRow"> <div class="innerTopRow"> <asp:ContentPlaceHolder ID="topRowContent" runat="server"></asp:ContentPlaceHolder> </div> </asp:Panel> <div ID="bottomRowPanel" class="bottomRow"> <asp:ContentPlaceHolder ID="bottomRowContent" runat="server"></asp:ContentPlaceHolder> </div> <script type="text/javascript"> function OnClientResizeText(sender, eventArgs) { var e = sender.get_element(); e.style.width = ''; $get("bottomRowPanel").style.top = e.clientHeight + 105; } </script> <ajaxToolkit:ResizableControlExtender ID="ResizableControlExtender" runat="server" TargetControlID="topRowPanel" HandleCssClass="handleTop" MinimumHeight="130" MinimumWidth="2000" MaximumWidth="2000" MaximumHeight="500" OnClientResizing="OnClientResizeText" HandleOffsetX="-1" />

Resize Accordion Pane

I have a few textboxes and requiredfieldvalidator s with a validationsummary inside an Accordion pane. When I click the submit button and the validationsummary shows its messages (at the top of the pane) it pushes the other controls down and some end up outside the pane. This is a Pain and was wondering if there is a way to make the accordion pane resize. Anybody have some Javascript or something that will help with this?

Awsome Thanks!

Sorry, posted before I read enough of the forum. SeemsThis isissue 1560 and their hoping to get it fixed by the next release. I did a slight workaround anyway: The other accordion pane I had was taller so I just added enough breaklines inside the offending pane which allowed for enough space for my validation summary to appear and just clip the breaklines out of the pane.

Although any ideas for a better solution would be greatly appreciated

Awsome Thanks!!

Resize animation with RoundedCorners

I have

<div id="div2" runat="server" style='width: 300px; height: 200px; background-color: teal; position: absolute;'>

and

<cc2:RoundedCornersExtender ID="RoundedCornersExtender1" runat="server">
<cc2:RoundedCornersProperties Radius="10" TargetControlID="div2"></cc2:RoundedCornersProperties>
</cc2:RoundedCornersExtender>

and

<cc2:AnimationProperties TargetControlID="div1">
<Animations><OnHoverOver>
<Resize AnimationTarget="div2" Width="500" Height="400" />
</OnHoverOver></Animations>
</cc2:AnimationProperties>

and when i hover over div1... only width changes. A bug?

Hi MarekG,

This is a consequence of the way that RoundedCorners works. It will wrap your target control in another div and set the height of the new div to be the same. If the inner height changes it won't propogate to the containing wrapper (i.e. you're resizing the wrapped control, but it's overflow is hidden by its wrapper so you see nothing happen).

Right now there isn't a way to work around this - but I hope to make some modifications to the Animation framework on the next release that will allow you to side step the issue.

Thanks,
Ted

Resize both panels at the same time with ResizableControlExtender

Hi;

Is it possible to resize two or more controls with the sameResizableControlExtender?

I mean just like in hotmail; when you enlarge left panel, right panel becomes automatically narrow

Thanks...

?


Hi,

You are actually referring to Splitter control, but as far as I know, this isn't available in AjaxControlToolkit yet( Please correct me if I'm wrong. ).

You may have to implement your own one or may try finding if there is any existing component.

Sorry for not being able to provide more help on this.


Thanks for your reply; u r right it's ain't there in AJAX v1;

I'll give a search for Splitter control cause theres no way to me to write mine own :D

Regards...


Actually I've found good examples here:

www.codeproject.com/useritems/VwdCmsSplitterBar.asp

Thanks...

Resize Behavior

I couldn't find where anyone had created a Resize Behavior (you know, to go along with the floatingBehavior so you can resize a "window")...

So I took a swing at it. You cantry it out hereand I alsoposted a blog entryon it.

Many thanks toGarbin, whose blog seems to currently be the best (or only?) source of documentation on behaviorsBig Smile [:D]

This is ULTRA cool and something I had been wondering about. Thanks for offering and implementation!

It works great!


Hi,

great work! Suggestion: what about an implementation of your ResizeBehavior based on the IDragSource and IDropTarget interfaces provided by the Atlas framework?

Hello,

thanks for your solution, always wondered how todo that.

However I get a JS-error:

Sys undefined

Probably I'm just missing a reference or something?!


You probably have one of two problems:

1. You are using the January CTP of Atlas, which uses a different namespace.

2. Something is wrong in your referencing of Atlas scripts, and the correct script files are not referenced in the proper order.

Hope this helps.


Thanks,

that helped!

It was an old CTP, you just spared me a lot of work.

Hi,

this articlefrom my blog could help you with the Atlas DragDrop system. Hope it helps.


It is quite cool that you can do something like that by plugging into the framework. It seems a little buggy though. It was resizing when I clicked on the page after I had finished dragging.

I created a product calledWebDialog that lets you achieve the same sort of effect. I can emphasise with how hard it is to get dragging and resizing right.

You can see some samples of what I did here: http://www.newtonsoft.com/products/webdialog/onlinedemo.aspx

Resize problem on nested CollapsiblePanels

I have a page with a number of collapsiblepanels, each with a nested panel inside it. The top main panel is open when the page loads, but the other panels and all sub-panels start off closed.

It looks something like this when the page is first opened:

----
| Panel1<Open>
| <text>
| Subpanel1 <closed>
---

---
| Panel2 <closed>
---

---
| Panel3 <closed>
---


Any manipulation of panels 2 and 3 or their sub-panels Not shown above) work fine. If I close and then re-open Panel1, it resizes correctly from that point on when subpanel1 is opened or closed. However, if the user clicks to open subpanel1 before any changes to panel1, the subpanel will open but the parent (panel1) will not expand to accommodate its contents.

Any way around this?


You mean to say that panel1 will not resize it self to accomodate the sub-panel1 expansion? Collapsible panels do not resize if the height/width of their content changes. They have a fixed expanded height and width. Have you set ScrollContents to true? That will allow you to view subpanel1 better. Does it clip your content currently? You could set expanded height to be something that will allow it to show subpanel1 contents without having to scroll.


kirtid:

You mean to say that panel1 will not resize it self to accomodate the sub-panel1 expansion?

Yes, that's the problem.


Collapsible panels do not resize if the height/width of their content changes. They have a fixed expanded height and width.


I left ExpandedSize blank and, set this way, Panel2 and Panel3 do in fact resize to fit the contents when SubPanel2 or SubPanel3 are changed - as does Panel1 when SubPanel1 is changed, but _only_ if Panel1 has been closed & opened by the user first.


Have you set ScrollContents to true? That will allow you to view subpanel1 better. Does it clip your content currently? You could set expanded height to be something that will allow it to show subpanel1 contents without having to scroll.

I'm hoping to avoid the scrolling panel if I can, and the contents of the subpanels varies in height so there's no "correct" fixed height to use. I'll scroll it if I have to but I'd rather get it to resize properly.



It seems like there is something specifically different about Panel1- subpanel1 config. Could you post a small, self-sufficient repro? It could be a styling issue.


Not pretty, but sufficient to illustrate the problem:

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title><style>.SiteLocHeader{width:100%;height:20px;background-image: url(../Images/bg-menu-small.gif);background-repeat:repeat-x;/* color:#FFF; */vertical-align: middle;}.SiteMainDiv { BORDER-RIGHT: #165EA9 7px solid;BORDER-LEFT: #165EA9 7px solid;BORDER-BOTTOM: #165EA9 7px solid;}.AddrHeaderTextLeft{font-family:verdana;font-size:x-small;font-weight:bold;/* color:white; */float: left;padding-left: 5px;vertical-align: middle;}.ArchiveHeader{background-color: #A5A5A5; color: #FFFFFF;font-family:verdana;font-size:x-small;font-weight:bold;padding-left: 5px;vertical-align: middle;}.SiteContactHeader{width:100%;height:20px;background-image: url(../Images/bg-menu-contact.png);background-repeat:repeat-x;/* color:#FFF; */vertical-align: middle;}.ContactHeaderTextLeft{font-family:verdana;font-size:x-small;font-weight:bold;/* color:#FFF; */float: left;padding-left: 5px;vertical-align: middle;}.SiteContactDiv {BORDER-RIGHT: #0398B8 7px solid;BORDER-LEFT: #0398B8 7px solid;BORDER-BOTTOM: #0398B8 7px solid;}</style></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div class="SiteLocHeader"> <div class="AddrHeaderTextLeft"> <asp:Image ID="imgShowAddrToggle" runat="server" ToolTip="Toggle view/edit of current Site Street, Phone, Fax & Web address information" ImageUrl="Images/collapse.jpg"></asp:image> Site Street, Phone, Fax & Web Address</div></div><asp:panel id="pnlSiteLoc" runat="server" cssclass="SiteMainDiv"><table class="table" width="100%" ><tr><td>Some fields & buttons go here</td></tr><tr><td> <asp:Panel runat="server" ID="pnlSiteArchHeader" CssClass="ArchiveHeader"> <asp:Image ID="imgSiteArchToggle" runat="server" ToolTip="Toggle display of archived site address records." ImageUrl="Images/expand.jpg"></asp:image> <asp:Label ID="lblSiteArch" runat="server" Text="Show Archives"></asp:Label> </asp:Panel><asp:Panel runat="server" ID="pnlSiteArchive"> Grid of archive info goes here</asp:Panel><ajaxToolkit:CollapsiblePanelExtender ID="cpeSiteArch" runat="server" CollapsedSize="0" Collapsed="true" ImageControlID="imgSiteArchToggle" ExpandedImage="~/Images/collapse.jpg" CollapsedImage="~/Images/expand.jpg" ExpandDirection="Vertical" TargetControlID="pnlSiteArchive" ExpandedText="Hide Archives" CollapsedText="Show Archives" CollapseControlID="imgSiteArchToggle" ExpandControlID="imgSiteArchToggle" TextLabelID ="lblSiteArch" /></td></tr></table></asp:panel><ajaxToolkit:CollapsiblePanelExtender ID="cpeSiteLoc" runat="server" CollapsedSize="0" Collapsed="false" ImageControlID="imgShowAddrToggle" ExpandedImage="~/Images/collapse.jpg" CollapsedImage="~/Images/expand.jpg" ExpandDirection="Vertical" TargetControlID="pnlSiteLoc" ExpandedText="Hide" CollapsedText="Show" CollapseControlID="imgShowAddrToggle" ExpandControlID="imgShowAddrToggle" /> <div class="SiteContactHeader"> <div class="ContactHeaderTextLeft"> <asp:Image id="imgContactToggle" runat="server" ToolTip="Toggle view/edit of current Site Contact information" ImageUrl="Images/collapse.jpg"></asp:image>  Site Contact</div></div><asp:panel ID="pnlSiteContact" runat="server" cssclass="SiteContactDiv"><table class="table" ><tr><td>More fields here</td></tr><tr><td colSpan="2"><asp:Panel runat="server" ID="pnlContactArchHeader" CssClass="ArchiveHeader"> <asp:Image ID="imgContArchToggle" runat="server" ToolTip="Toggle display of archived Contact records." ImageUrl="Images/expand.jpg"></asp:image> <asp:Label ID="lblContArch" runat="server" Text="Show Archives"></asp:Label> </asp:Panel><asp:Panel runat="server" ID="pnlContArchive">More archive info in this sub-panel</asp:Panel><ajaxToolkit:CollapsiblePanelExtender ID="cpeContArchive" runat="server" CollapsedSize="0" Collapsed="true" ImageControlID="imgContArchToggle" ExpandedImage="~/Images/collapse.jpg" CollapsedImage="~/Images/expand.jpg" ExpandDirection="Vertical" TargetControlID="pnlContArchive" ExpandedText="Hide Archives" CollapsedText="Show Archives" CollapseControlID="imgContArchToggle" ExpandControlID="imgContArchToggle" TextLabelID ="lblContArch" /></td></tr></table></asp:panel><ajaxToolkit:CollapsiblePanelExtender ID="cpeSiteContact" runat="server" CollapsedSize="0" Collapsed="true" ImageControlID="imgContactToggle" ExpandedImage="~/Images/collapse.jpg" CollapsedImage="~/Images/expand.jpg" ExpandDirection="Vertical" TargetControlID="pnlSiteContact" ExpandedText="Hide" CollapsedText="Show" CollapseControlID="imgContactToggle" ExpandControlID="imgContactToggle" /> </form></body></html>

I got the same problem and would be very interested in a solution, too.

In my case, I have a nested UpdatePanel inside a Panel extended with CollapsiblePanelExtender. The panel opens fine, but if the UpdatePanel grows after a partial update, the collapsible panel does not resize to fit it's new content. I also did not set the ExpandedSize property to have the panel autofit it's content. If I collapse and expand the collapsible panel again after an update to the UpdatePanel, it sizes itself correctly to the new size.


I tried this and the TargetPanel expanded fine after the partial update. In the example attached the collapsible panels expand fine. Is there somethng in my sample I need to tweak?

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Panel runat="Server" ID="Panel1Header" BackColor="Pink" Height="30">
</asp:Panel>
<asp:Panel runat="Server" ID="Panel1" Height="0" BackColor="Red">
<asp:Panel runat="server" ID="subpanel1Header" Height="30">
</asp:Panel>
<asp:Panel runat="Server" ID="subpanel1">
<asp:UpdatePanel runat="Server" ID="updatepanel1">
<ContentTemplate>
<asp:Button runat="server" ID="button1" OnClick="button1_Click" Text="expand panel" />
<asp:Label runat="server" ID="label1"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<ajaxToolkit:CollapsiblePanelExtender runat="server" ID="CollapsiblePanelExtender1" TargetControlID="SubPanel1"
CollapseControlID="SubPanel1Header" ExpandControlID="SubPanel1Header" CollapsedText="Expand subpanel..."
Collapsed="true" ExpandedText="Collapse subpanel...">
</ajaxToolkit:CollapsiblePanelExtender>
</asp:Panel>
<ajaxToolkit:CollapsiblePanelExtender runat="server" ID="cpOuter" TargetControlID="Panel1"
CollapseControlID="Panel1Header" ExpandControlID="Panel1Header" CollapsedText="Expand..."
Collapsed="true" ExpandedText="Collapse">
</ajaxToolkit:CollapsiblePanelExtender>

protected void button1_Click(object sender, EventArgs e) {this.label1.Text ="sxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslg sxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslg sxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslgsxjghsghsghdhslg"; }


Yes, you have to ;)

The UpdatePanel should server like a pseudo DynamicPopulate, just without the web service call. So the idea is, that I have multiple collapsible panels in parallel forming a list with collapsible content. The inner controls of the panels are not yet initialized, i.e. the controls do not exist yet. So if now a panel is expanded the postback to the server for the UpdatePanel is made while the panel is expanding - so there is even a racing condition. You modified example would look like this:

<asp:ScriptManagerID="ScriptManager1"runat="server"/>
<div>
<asp:Panelrunat="Server"ID="Panel1Header"BackColor="LightBlue"Height="30">
<asp:LabelID="Label2"runat="server"onclick="document.getElementById('button1').click()">click me</asp:Label>
</asp:Panel>
<asp:Panelrunat="Server"ID="Panel1"Height="0"BackColor="Gray">
<asp:UpdatePanelrunat="Server"ID="updatepanel1">
<ContentTemplate>
<asp:Buttonrunat="server"ID="button1"OnClick="button1_Click"Text="expand panel"/>
<asp:Labelrunat="server"ID="label1"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<ajaxToolkit:CollapsiblePanelExtenderrunat="server"ID="cpOuter"TargetControlID="Panel1"
CollapseControlID="Label2"ExpandControlID="Label2"CollapsedText="Expand..."
Collapsed="true"ExpandedText="Collapse">
</ajaxToolkit:CollapsiblePanelExtender>


A better option is to actually raise events in the CollapsiblePanel before collapsing/expanding and after collapsed/expanded actions are done. We do plan to add those. You can perform any databinding/ partial post backs in those.

I am not hitting the race condition.

Here is what I tried:

 <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager2" runat="server" /> <div> <asp:UpdatePanel runat="server" ID="updatePanelOuter"> <Triggers> <asp:AsyncPostBackTrigger ControlID="image1" /> </Triggers> <ContentTemplate> <asp:Panel runat="Server" ID="Panel1Header" BackColor="LightBlue" Height="30"> <asp:ImageButton ID="image1" runat="server" ImageUrl="~/Calendar.gif" OnClick="button1_Click"> </asp:ImageButton> </asp:Panel> <asp:Panel runat="Server" ID="Panel1" Height="0" BackColor="Gray"> <asp:Label runat="server" Text="Fooooo"></asp:Label> <asp:UpdatePanel runat="Server" ID="updatepanel1"> <ContentTemplate> <asp:Button runat="server" ID="button1" Visible="false" OnClick="button1_Click" Text="expand panel" /> <asp:GridView ID="GridView1" runat="server" AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None"> <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#FFFBD6" ForeColor="#333333" /> <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" /> <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" /> <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" /> </asp:GridView> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="Select" TypeName="SessionTodoXmlDataObject" UpdateMethod="Update"> <DeleteParameters> <asp:Parameter Name="Original_ItemID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="Title" Type="String" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Priority" Type="Int32" /> <asp:Parameter Name="Original_ItemID" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="Title" Type="String" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Priority" Type="Int32" /> </InsertParameters> </asp:ObjectDataSource> <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/TodoItems.xml"> </asp:XmlDataSource> </ContentTemplate> </asp:UpdatePanel> </asp:Panel> <ajaxToolkit:CollapsiblePanelExtender runat="server" ID="cpOuter" TargetControlID="Panel1" CollapseControlID="image1" ExpandedSize="-1" ExpandControlID="image1" CollapsedText="Expand..." Collapsed="true" ExpandedText="Collapse" ImageControlID="image1"> </ajaxToolkit:CollapsiblePanelExtender> </ContentTemplate> </asp:UpdatePanel> </div> <asp:Panel runat="Server" ID="Panel2" BackColor="Lime" Height="30"> <asp:Label ID="Label2" runat="server" >FooooooooooooooooooBarrrrrrrrrrrrrrrrrrrrrrrr</asp:Label> </asp:Panel> <asp:Panel runat="Server" ID="Panel3" Height="0" BackColor="Gray"> FooooooooooooooooooBarrrrrrrrrrrrrrrrrrrrrrrr FooooooooooooooooooBarrrrrrrrrrrrrrrrrrrrrrrr FooooooooooooooooooBarrrrrrrrrrrrrrrrrrrrrrrr FooooooooooooooooooBarrrrrrrrrrrrrrrrrrrrrrrr FooooooooooooooooooBarrrrrrrrrrrrrrrrrrrrrrrr </asp:Panel> <ajaxToolkit:CollapsiblePanelExtender runat="server" ID="CollapsiblePanelExtender1" TargetControlID="Panel3" CollapseControlID="Label2" ExpandControlID="Label2" CollapsedText="Expand..." Collapsed="true" ExpandedText="Collapse"> </ajaxToolkit:CollapsiblePanelExtender>

protected void button1_Click(object sender, EventArgs e) {this.GridView1.DataSourceID ="ObjectDataSource1";this.GridView1.DataBind(); }

Resized image wont show in UpdatePanel

Hello,

I have a problem with a code where I want to resize an image in a Update Panel but when I fire up my site, I get this error in a message box:

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Details: Error parsing near '???JFIF'.

This is the code of the aspx page where the subs are called to resize and show the image (The formview is in a UpdatePanel):

1 <asp:FormView ID="DetailsFormView" runat="server" DataSourceID="DetailsFormSource">
2 <ItemTemplate>
3 <table style="vertical-align: top; text-align: left; width: 100%;">
4 <tr>
5 <td style="width: 150px; font-weight: bold;">
6 Initials:</td>
7 <td style="width: 278px">
8 <asp:Label ID="InitialerLabel" runat="server" Text='<%# Bind("Initialer")%>'></asp:Label></td>
9 <td rowspan="14" style="width: 188px">
10<%
11 ' make sure Nothing has gone to the client
12 Response.Clear()
13
14
15 If SearchGridView.SelectedValue = "" Then
16
17 Call sendError()
18
19 Else
20 If File.Exists(Server.MapPath("images/foto/" & SearchGridView.SelectedValue & ".jpg")) Then
21 Call sendFile()
22 Else
23 Call sendError()
24 End If
25
26 End If
27
28 Response.End()
29%>30 <asp:Image ID="EmpImg" runat="server" />
31 </td>
32 </tr>
33 <tr>
34 <td style="width: 150px; font-weight: bold;">
35 Full Name:</td>
36 <td style="width: 278px">
37 <asp:Label ID="FornavnLabel" runat="server" Text='<%# Bind("Fornavn")%>'></asp:Label>
38 <asp:Label ID="EfternavnLabel" runat="server" Text='<%# Bind("Efternavn")%>'></asp:Label></td>
39 </tr>
40 <tr>
41 <td style="width: 150px; font-weight: bold;">
42 Employee Nr.:
43 </td>
44 <td style="width: 278px">
45 <asp:Label ID="MedarbnrLabel" runat="server" Text='<%# Bind("Medarbnr")%>'></asp:Label></td>
46 </tr>
47 <tr>
48 <td style="width: 150px; font-weight: bold;">
49 Department code:</td>
50 <td style="width: 278px">
51 <asp:Label ID="afdelingskodeLabel" runat="server" Text='<%# Bind("afdelingskode")%>'>
52 </asp:Label></td>
53 </tr>
54 <tr>
55 <td style="width: 150px; font-weight: bold;">
56 Private address:</td>
57 <td style="width: 278px">
58 <asp:Label ID="padresseLabel" runat="server" Text='<%# Bind("padresse")%>'></asp:Label>,
59 <asp:Label ID="ppostnrLabel" runat="server" Text='<%# Bind("ppostnr")%>'></asp:Label>
60 <asp:Label ID="Bynavn" runat="server" Text='<%# Bind("Bynavn")%>'></asp:Label></td>
61 </tr>
62 <tr>
63 <td style="width: 150px; font-weight: bold;">
64 Private phone:</td>
65 <td style="width: 278px">
66 <asp:Label ID="ptelefonLabel" runat="server" Text='<%# Bind("ptelefon")%>'></asp:Label></td>
67 </tr>
68 <tr>
69 <td style="width: 150px; font-weight: bold;">
70 Private cellphone:</td>
71 <td style="width: 278px">
72 <asp:Label ID="pmobilLabel" runat="server" Text='<%# Bind("pmobil")%>'></asp:Label></td>
73 </tr>
74 <tr>
75 <td style="width: 150px; font-weight: bold;">
76 Phone:</td>
77 <td style="width: 278px">
78 <asp:Label ID="telefonLabel" runat="server" Text='<%# Bind("telefon")%>'></asp:Label></td>
79 </tr>
80 <tr>
81 <td style="width: 150px; font-weight: bold;">
82 Cellphone / Shortnr:</td>
83 <td style="width: 278px">
84 <asp:Label ID="mobil1Label" runat="server" Text='<%# Bind("mobil1")%>'></asp:Label>
85 /
86 <asp:Label ID="mobil2Label" runat="server" Text='<%# Bind("mobil2")%>'></asp:Label></td>
87 </tr>
88 <tr>
89 <td style="width: 150px; font-weight: bold;">
90 Mail address:
91 </td>
92 <td style="width: 278px">
93 <asp:Label ID="mailLabel" runat="server" Text='<%# Bind("mail")%>'></asp:Label>@dotnet.itags.org.***.com</td>
94 </tr>
95 <tr>
96 <td style="width: 150px; font-weight: bold;">
97 Private mail:</td>
98 <td style="width: 278px">
99 <asp:Label ID="pmailLabel" runat="server" Text='<%# Bind("pmail")%>'></asp:Label></td>
100 </tr>
101 <tr>
102 <td style="width: 150px; font-weight: bold;">
103 Based:
104 </td>
105 <td style="width: 278px">
106 <asp:Label ID="hjemh?rendeLabel" runat="server" Text='<%# Bind("hjemh?rende")%>'>
107 </asp:Label></td>
108 </tr>
109 <tr>
110 <td style="width: 150px; font-weight: bold;">
111 Position:</td>
112 <td style="width: 278px">
113 <asp:Label ID="StillingLabel" runat="server" Text='<%# Bind("Stilling")%>'></asp:Label></td>
114 </tr>
115 <tr>
116 <td style="width: 150px; font-weight: bold;">
117 Vehicle nr.:</td>
118 <td style="width: 278px">
119 <asp:Label ID="vognnrLabel" runat="server" Text='<%# Bind("vognnr")%>'></asp:Label></td>
120 </tr>
121 </table>
122 </ItemTemplate>
123 </asp:FormView>
124

And this are the subs that is resizing the image:

 
1Function NewthumbSize(ByVal currentwidth,ByVal currentheight)
234' Calculate the Size of the New image56Dim tempMultiplierAs Double
78 If currentheight > currentwidthThen' portrait9 tempMultiplier = 200 / currentheight
10Else11 tempMultiplier = 200 / currentwidth
12End If
131415 Dim NewSizeAs New Size(CInt(currentwidth * tempMultiplier),CInt(currentheight * tempMultiplier))
1617Return NewSize
18End Function
192021 Public Sub sendFile()
2223' create New image and bitmap objects. Load the image file and put into a resized bitmap.24Dim gAs System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath("images/foto/" & SearchGridView.SelectedValue &".jpg"))
25Dim thisFormat = g.RawFormat
2627Dim thumbSizeAs New Size
28 thumbSize = NewthumbSize(g.Width, g.Height)
2930Dim imgOutputAs New Bitmap(g, thumbSize.Width, thumbSize.Height)
3132' Set the contenttype3334 Response.ContentType ="image/jpeg"353637 imgOutput.Save(Response.OutputStream, thisFormat)' output to the user
3839 ' tidy up40 g.Dispose()
41 imgOutput.Dispose()
4243End Sub
4445 Public Sub sendError()
4647' if no height, width, src then output "error"48Dim imgOutputAs New Bitmap(120, 120, PixelFormat.Format24bppRgb)
49Dim gAs Graphics = Graphics.FromImage(imgOutput)' create a New graphic object from the above bmp50 g.Clear(Color.Yellow)' blank the image51 g.DrawString("ERROR!",New Font("verdana", 14, FontStyle.Bold), SystemBrushes.WindowText,New PointF(2, 2))
52' Set the contenttype53 Response.ContentType ="image/gif"5455' send the resized image to the viewer56 imgOutput.Save(Response.OutputStream, ImageFormat.Gif)' output to the user
5758 ' tidy up59 g.Dispose()
60 imgOutput.Dispose()
61End Sub

I search a bit on the the what the problem could be, and I didn't find enything than that Response.Write can't be used, but I didn't hear nothing about the others Response methods that I am using.

You can't inject that type of data into the response stream of a partial postback. It boils down to the exact same problem as using Response.Write.

If I were you, I'd change that to a regular image control with the ImageURL dynamically assigned through code similar to what you have. If the thumbnail already exists, your function can return the path/file to it. If not, it creates the thumbnail and then returns the path/file. If there's an error, it can return the path/file of that error GIF.


Hmm.. I thought about your idea but I don't want to have the images two times.

But I got the problem solved.

I made an file called Thumbnail.aspx and in it I wrote:

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="Thumbnail.aspx.vb" Inherits="Thumbnail" ContentType="image/jpeg" %>

And in Tumbmail.aspx.vb I added this code:

Imports System
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Imaging
PartialClass Thumbnail
Inherits System.Web.UI.Page

Private PathToImageAs String ="images/foto/"Sub sendFile()
' create New image and bitmap objects. Load the image file and put into a resized bitmap.Dim gAs System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath(PathToImage & Request("src")))
Dim thisFormat = g.RawFormat
Dim imgOutputAs New Bitmap(g, 177, 239)

' Set the contenttype Response.ContentType ="image/jpeg"' send the resized image to the viewer imgOutput.Save(Response.OutputStream, thisFormat)' output to the user

' tidy up g.Dispose() imgOutput.Dispose()End Sub

Sub sendError()

' create New image and bitmap objects. Load the image file and put into a resized bitmap.Dim gAs System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath("images/noimage.jpg"))
Dim thisFormat = g.RawFormat
Dim imgOutputAs New Bitmap(g, 177, 239)

' Set the contenttype Response.ContentType ="image/jpeg"' send the resized image to the viewer imgOutput.Save(Response.OutputStream, thisFormat)' output to the user

' tidy up g.Dispose() imgOutput.Dispose()End Sub

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.Load

' make sure Nothing has gone to the client Response.clear()If Request("src") ="" Then
Call sendError()

Else

If File.Exists(Server.MapPath("PathToImage & Request("src")))Then
Call sendFile()
Else
Call sendError()
End If

End If response.end()End Sub
End Class

And in my formview I added this to display the image:

<img src="http://pics.10026.com/?src=Thumbnail.aspx?src=<%# SearchGridView.SelectedValue %>.jpg" alt="" style="border: 0px" />

That works for me,

Resizing DIV according to collapsiblePanel state

Hello,

I'm trying to resize a div on the moment the collapsiblePanel either expands or collapses.

The page I have is roughly like follows;

1<table>2 <tr>3 <td>4 <div id="cpPanelHeader">5 panel header6 </div>7 <div id="cpPanelContent">8 panel content9 </div>10 <ACT:CollapsiblePanelExtender11 TargetControlID="cpPanelContent"12 ExpandControlID="cpPanelHeader"13 CollapseControlID="cpPanelHeader" />14 </td>15 </tr>16 <tr>17 <td>18 <div id="PageContent">19 main page content20 </div>21 </td>22 </tr>23</table>

the first table cell houses some general information, enclosed in the collapsible panel. the second table cell houses the page content.

on the moment that the collapsible panel collapses or expands i want to make sure the main page content is spread over the available space. therefore i want to be able to set the height property of the PageContent div. I first tried some codebehind to set the style.height of the div, but this prop is read only. then i changed the div into a panel, and set the panel.height prop. this didn't seem to work; the panel did not shrink or grow, no matter what value I set the height to. Then i tried to use client javascript, but i cant get hold of the panelstate inside of the javascript.

Can anyone point out to me how to solve this problem?

Regards,

Francois

Hi Francois,

You can add event handler for the panel's collapsed and expanded event, and resize the div in the handler.

First, assign a behaviorID to the CollapsiblePanelExtender;

Second, retrieve it with $find method;

Third, Add event handler for it;

For instance:

<ajaxToolkit:CollapsiblePanelExtender ID="cpeDemo"BehaviorID="cpe"...... />

function pageLoad()

{

var cpb = $find("cpe");

cpb.add_expanded(myFunction1); cpb.add_collapsed(myFunction2);

}

function myFunction1() {//resize div here}

Hope this helps.


Hello Raymond,

I'm fiddling with your approach. one thing that doesn't work yet is the adding of the event handlers.

the code I have is as follows;

 function OnLoad() { alert('OnLoad'); var cpb = $find('cpBID'); cpb.add_expanded(ResizeDIVOnPanelExpanded); cpb.add_collapsed(ResizeDIVOnPanelCollapsed); } function ResizeDIVOnPanelExpanded() { alert('OnPanelExpanded'); } function ResizeDIVOnPanelCollapsed() { alert('OnPanelCollapsed'); }

I registered this code with the scriptmanager as follows;

protected void Page_Load(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this,typeof(GS_CasusAanpassen),"start","OnLoad();",true); }

Now, I do get the OnLoad message. but after that it's all quit. is it something I did wrong with adding the event handlers?

Or do I have to set the script on another place?

Kind Regards and thanks for helping out!

Francois


Finally Big Smile

It seems I was hooking up the wrong events. while searching throught the forum I stumbled accross the following thread;

http://forums.asp.net/p/1112899/1721250.aspx#1721250

Following that thread I solved my problem as follows:

 <script language="javascript" type="text/javascript"> function pageLoad() { var cpb = $find("collapsibleBehavior"); cpb.add_expandComplete( ResizeDIVOnPanelExpanded ); cpb.add_collapseComplete( ResizeDIVOnPanelCollapsed ); } function ResizeDIVOnPanelExpanded() { document.getElementById('MainContentDIV').style.height = '250px'; } function ResizeDIVOnPanelCollapsed() { document.getElementById('MainContentDIV').style.height = '500px'; } </script>
This works well. It would be nice thought if the size would change fluently and not at once. a bit like the collapsible panel itself maybe.

2012年3月24日土曜日

Rounded Corner Extender has problems with dynamic panels

I'm trying to create some panels, which are "glued" to the top and bottom, so the panel resize together with browser. It works fine, until I attach a Rounded Corner Extender. Then the rounded corners are positioned correct with the top, but the height are fixed somewhere near the top.

Here are the panel I try to add rounded corners to:

<asp:PanelID="PanelSideBar"runat="server"Style="position: absolute; top: 100px;left: 10px; bottom: 25px; width: 200px"BackColor="Beige"></asp:Panel>

<

ajaxToolkit:RoundedCornersExtenderID="RCExtender"runat="server"TargetControlID="PanelSideBar"></ajaxToolkit:RoundedCornersExtender>Thanks for reporting this. I have opened work itemhttp://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=8769 for this.