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

2012年3月28日水曜日

Reset controls in update panel when error is thrown

Hello fellow developers,

A user enters a value in a textbox and i click a button to get some data, but a server error is thrown.

Is there a way to clear/reset the textbox in an UpdatePanel when there is a server error?

If there is a way, can someone assist in providing me that trick?

Thanks in Advance.

Protected Sub myButton_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles myButton.Click
Try
' Whatever code that I'm trying to run goes here.
' This is the code that my produce the error.
Catch
myTextbox.Text =""
End Try
End Sub


Can't you simply use a try/catch block, and catch the exception? If an exception is thrown reset it to the old value. You can use a hidden label or textbox to store the previous value.


Use this

protected void ScriptManager1_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)
{
if (condition)
{
ScriptManager1.AsyncPostBackErrorMessage =
e.Exception.Message;

}
else
{
ScriptManager1.AsyncPostBackErrorMessage =
"An unspecified error occurred.";
}
}


I apologize. My example scenario was not explained the way I originally thought.

The example should be that when using AJAX you want to show an error message AND reset the controls.

If you write code to 'Throw' a custom error message to an alert window, nothing after the 'Throw' gets executed (clearing my textbox).

So my question really should be:

Is there a way, using AJAX, to 'Throw' a custom error message to an alert window and still reset controls? Either on the server or client side.

Thanks.


Protected Sub myButton_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles myButton.Click
Try
' Whatever code that I'm trying to run goes here.
' This is the code that my produce the error.
Catch exAs Exception
ScriptManager.RegisterStartupScript(Page, Page.GetType,"ErrorMsg", "alert('" & ex.Message & "');",True)
myTextbox.Text =""
End Try
End Sub


Thanks Buddha, that's just what I needed.

Resizable Control Extender

I have a Panel with scrollbars set to auto, a TreeView control with enough nodes to trigger the scroll bars,

and a Resizable Control Extender attached to the Panel.

The Resizable Control Extender will work perfectly as long as you don't scroll the Tree.

If you scroll the Tree the Handle will move vertically by the amount of the Tree scroll.

If you scroll too far the handle will disapear from the screen leaving you without a way to resize the Panel.

Does anyone know of a way to keep the handle in it's original postion?

Thanks,

Larry

Can you post your code?? Even I am stuck on a similar issue...may be we might be able to help each other.

Karamchand

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...... !!!

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 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 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,

ResizeControlExtender causes panel to have 0px width and 0px height

All,

I am adding a ResizeControlExtender to a panel that already has a DragPanelExtender and am getting some very odd behavior. The window I want to resize is created dynamically and I add the ajax extender programatically as well. I am able to put a resize handle on the popup window but when I mouse over the handle the panel collapses to 0px width and 0px height. I have specified all of the properties as follows:

ResizableControlExtender resizeWindow = new ResizableControlExtender();

resizeWindow.ID = "timePanelResize" + i;
resizeWindow.TargetControlID = "timePanel" + i;
resizeWindow.HandleCssClass = "handleImage";
resizeWindow.ResizableCssClass = "resize";
resizeWindow.MinimumWidth = 200;
resizeWindow.MaximumWidth = 200;
resizeWindow.MinimumHeight = 24;
resizeWindow.MaximumHeight = 600;
resizeWindow.HandleOffsetX = 186;
resizeWindow.HandleOffsetY = 187;
dragWindowPanel.Controls.Add(resizeWindow);

I am using c#, .Net 2.0, AJAX v1.0.61025, IE 7 and Firefox 2.01. on mouse over the following behavior occurs; In IE it flickers and collapses in Firefox it flickers and the height collapses to the min height. Also, the handle is extremely difficult to grab... Also, the mouse must be in exactly the right pixel position (about 1px wide and tall) in order to grab the handle.

Anybody else see behavior like this? If so, is there a solution?

Thanks,

Kevin

There's an old forum thread about this, but the gist is that you add another Panel/DIV wrapper so the two extenders can point at/modify different HTML elements.

Resizing a panel using Animation Extender

Hi Everyone,

I have 3 rows of images on my form and each row has 3 images as well. I want to have a effect so that when the user hovers on a row than that row expands itself and the rest of the rows remain the same size.

To do this I used 3 panels and in each panel I inseted a table so as to accomodate the 3 images.

Then to add the Hover effect I used the Animation extender control. The code that I used is given below.

<cc1:AnimationExtenderID="AnimationExtender1"runat="server"TargetControlID="Panel1">

<Animations>

<OnHoverOver>

<ParallelDuration=".1"fps="50">

<ResizeWidth="250"Height="260" />

</Parallel>

</OnHoverOver>

</Animations>

</cc1:AnimationExtender>

However this doesn't seem to work. Any idea about why this is happening. It seems to me that I am making a really basic mistake but I have been trying to make this work for quite some days with no success.

If anyone has any idea what the problem is here please let me know.

Thanks

Hi,

I created a sample that works fine according to your description, please try it:

<%@. 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></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <table> <tr> <td> <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/Add.gif" Height="50" Width="50"/> <ajaxtoolkit:AnimationExtender ID="AnimationExtender1" runat="server" TargetControlID="Image1"> <Animations> <OnHoverOver> <Parallel Duration=".1" fps="50"> <Resize Width="250" Height="250" /> </Parallel> </OnHoverOver> <OnHoverOut> <Parallel Duration=".1" fps="50"> <Resize Width="50" Height="50" /> </Parallel> </OnHoverOut> </Animations> </ajaxtoolkit:AnimationExtender> </td> <td> <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/edit.gif" Height="50" Width="50"/> <ajaxtoolkit:AnimationExtender ID="AnimationExtender2" runat="server" TargetControlID="Image2"> <Animations> <OnHoverOver> <Parallel Duration=".1" fps="50"> <Resize Width="250" Height="250" /> </Parallel> </OnHoverOver> <OnHoverOut> <Parallel Duration=".1" fps="50"> <Resize Width="50" Height="50" /> </Parallel> </OnHoverOut> </Animations> </ajaxtoolkit:AnimationExtender> </td> <td> <asp:Image ID="Image3" runat="server" ImageUrl="~/Images/delete.gif" Height="50" Width="50"/> <ajaxtoolkit:AnimationExtender ID="AnimationExtender3" runat="server" TargetControlID="Image3"> <Animations> <OnHoverOver> <Parallel Duration=".1" fps="50"> <Resize Width="250" Height="250" /> </Parallel> </OnHoverOver> <OnHoverOut> <Parallel Duration=".1" fps="50"> <Resize Width="50" Height="50" /> </Parallel> </OnHoverOut> </Animations> </ajaxtoolkit:AnimationExtender> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> </div> </form></body></html>

Thanks Raymond that surely helps....

However I have another problem and it will be great if you can have a look at that also....

http://forums.asp.net/p/1168745/1950736.aspx#1950736

Thanks in advance

vishy

Resizing the Ajax ResizableControlExtender durning the OnLoad event

I'm having a problem with the Ajax ResizableControlExtender.

The control is around an asp panel, which is around a gridview. The gridview is really wide, and I need the headers to stay at the top when scrolling down. That's working just fine.

I have a body onresize javascript event that resizes the ResizableControlExtender to fit better on the screen whenever the screen is resized.

What I need to do is have the resize event fire on the "OnLoad" event.

But at that time the ResizableControlExtender has not been initialized (or so I suppose) and is undefined at that time.

Is there a way to resize the ResizableControlExtender to the current window size in the page load event?

Thanks.

Chuck Snyder

Hi Chuck,

Based on my understanding, the pageLoad method is fired after all extenders on the page have been initialized. But if it doesn't work with you, please try to use window.setTimeout method to invoke the resize method in pageLoad, so that it will be called asynchronized at later.

For instance:

function pageLoad() { window.setTimeout(resize, 1000); }

2012年3月26日月曜日

Response.redirect causes post back using Atlas


Hi,

I have a webpage with a button on it. The button is placed in an update panel. I want to redirect user to another page when the user press the button. Basically it is a save button which save user information and redirect user to another page.

I tried using response.redirect("anotherpage.aspx") but it caused post back however the button is placed under a n update panel.

Can anyone help me out? I want to save data on button click and redirect user to another page without causing post back.


Thanks.
Imtiaz

Redirect has to cause a postback, you are trying to "redirect" the user.

Firstly, all things inside an update panel cause a postback, they just go through some different steps, and only deal with events in the update panel, and only refresh the part of the page inside the panel.

So your button is designed to postback, which it does... then redirects, the update panel picks this up, and changes the browser page.

The functionality is correct.

If you want, instead of a button with a redirect, make a regular html button with a clientside event.

onclick="redirect();"

function redirect(){

location.herf = 'newURL.aspx';

}

If you call a client side method to change the location of the page, then there is no post back to the server

Response.Redirect doesnt work with UpdatePanel in Beta 1

I have a page with an update panel that contains a few buttons that need to be able to redirect to another page. The script manager is located on a master page.

Every time one of those buttons are clicked, i get one of two errors:

    If the button is inside of a gridview, i get this error:
    Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.
    If the button is NOT inside of a gridview, i get this error:
    Sys.WebForms.PageRequestManagerParserErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 302

Here's a test aspx page that I set up:

1<%@dotnet.itags.org. Page Language="VB" title="Untitled Page" MasterPageFile="~/main.master" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>2<%@dotnet.itags.org. Register Assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Web.UI" TagPrefix="ajax" %>3<asp:Content ID="Content1" ContentPlaceHolderID="plhContent" Runat="Server">4 <ajax:UpdatePanel runat="server">5 <ContentTemplate>6 <asp:Label runat="server" ID="lblTime" /><br />7 <asp:Button runat="server" ID="btnRefresh" Text="Refresh" /><br />8 <asp:Button runat="server" ID="btnRedirect" Text="Redirect" /><br />9 <asp:LinkButton runat="server" ID="lnkRedirect" Text="ASP Linkbutton" /><br />10 <a href="http://www.google.com/" title="test redirect">HTML Hyperlink</a>11 </ContentTemplate>12 </ajax:UpdatePanel>13</asp:Content>
And here's the codebehind:
1PartialClass test2Inherits System.Web.UI.Page34Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.Load5 lbltime.Text = now()6End Sub78 Protected Sub btnRedirect_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles btnRedirect.Click9 Response.Redirect("http://www.google.com/",True)10End Sub1112 Protected Sub btnRefresh_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles btnRefresh.Click13 lblTime.Text = Now()14End Sub1516 Protected Sub lnkRedirect_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles lnkRedirect.Click17 Response.Redirect("http://www.google.com/",True)18End Sub19End Class


The LinkButton causes the same error, so it's not just limited to the button control. It looks like it affect anything that posts back to the server and causes a redirect.

Thanks for any help you can give me!

We found this out today too. The fix is to pass a location.href back to user.

ScriptManager.RegisterStartupScript(pnlYourUpdatePanel,this.GetType(),"redirectMe","location.href='blah.aspx';",true);

Sorry it is in C#... Hope this helps.


hello.

i've just built a sample project with the following code:

master page:

<%@. Master Language="VB" %
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:scriptmanager runat="server" ID="manager" />
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>

page:

<%@. Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>
<script runat="Server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
lblTime.Text = Now()
End Sub

Protected Sub btnRedirect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRedirect.Click
Response.Redirect("http://www.google.com/", True)
End Sub

Protected Sub btnRefresh_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
lblTime.Text = Now()
End Sub

Protected Sub lnkRedirect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkRedirect.Click
Response.Redirect("http://www.google.com/", True)
End Sub
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:updatePanel runat="server" id="panel">
<contenttemplate>
<asp:Label runat="server" ID="lblTime" /><br />
<asp:Button runat="server" ID="btnRefresh" Text="Refresh" /><br />
<asp:Button runat="server" ID="btnRedirect" Text="Redirect" /><br />
<asp:LinkButton runat="server" ID="lnkRedirect" Text="ASP Linkbutton" /><br />
<a href="http://links.10026.com/?link=http://www.google.com/" title="test redirect">HTML Hyperlink</a>
</contenttemplate>
</asp:updatePanel>
</asp:Content
everything is working here with the beta extensions. are you sure you've set up web.config correctly?


Luis,

When looking at the XMLHttpResponse google.com is being returned which is causing the parser error. Not sure how you are getting this to work with the Beta release?? Also, not sure how config would cause this?

Matt


hello.

well just recalled one problem i've seen before where the users updated the prefix but left it pointing to the old ctp dll which was still in the bin folder and it just blow everything apart. btw, here's what i'm getting back from the server side in response to a click over the redirect button (2nd one from the top):


22|pageRedirect||http://www.google.com/|


Luis Abreu:

everything is working here with the beta extensions. are you sure you've set up web.config correctly?

I think I do. I have a Microsoft.Web.Extensions assembly in the web.config. Is there aything else I need?

1<compilation debug="true" strict="false" explicit="true">2 <assemblies>3 <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>4 <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>5 <add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>6 </assemblies>7</compilation>


Luis Abreu:

well just recalled one problem i've seen before where the users updated the prefix but left it pointing to the old ctp dll which was still in the bin folder and it just blow everything apart.

I did delete the old CTP DLL, and added the new assembly registration to the top of the page:

1<%@. Register Assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Web.UI" TagPrefix="ajax" %>2

hello again.

can you confirm the response you're getting back from the server? is it similar to the one i've shown before?


How do I access the server response information?

hello.

use fiddler. if you're using ie, you must create a site in IIS and then use the name of the machine (http://machinename/site). if you're using firefox, configure it so that it uses a local proxy (127.0.0.1 port 8888 if i'm not mistaken).


It is definitely in the config. Again... good call Luis... you are missing these values in your config and this should cure the problem.

<httpModules><add name="WebResourceCompression" type="Microsoft.Web.Handlers.WebResourceCompressionModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add name="ScriptModule" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></httpModules>
Thank Luis for that one. =)
P.S. That is under httpHandlers

That worked! You guys are awesome.


Thanks!


Thanks - Guys!

I was experiencing the same problem in Beta 2, which this solution apparently resolved that issue.


Hi Guys!

I Got the Same error in my current project. I cant redirect to another page from inside the UpdatePanel. Finally I saw this forum and got a wonder result and answer. Its really amazing and thanks a lot for u all guys..

rgds,

Senthil

Response.Redirect from UpdatePanel causes full refresh

I noticed that when I redirect to another page from within an update panel, the page fully refreshes (may be that's by design?).

How can I prevent this from happening?

Thanks.

you can not prevent this, this is the way any web sites works. When you say response.redirect, you are instructing the browser to make a fresh call to particular aspx page.


rmaiya:

you can not prevent this, this is the way any web sites works. When you say response.redirect, you are instructing the browser to make a fresh call to particular aspx page.

that is right.

If you are trying to only update the panel then try something like, updatePanel1.update();, or if you want to load a new page inside the panel try putting an iframe inside the panel


What is considered as best practice?

For example, if you click on the above links (such as "Learn", "Downloads", "Ajax"...) on this page, how do they ensure that that the header and footer elements of the page don't "blink"?


As they are different pages, I do want to do a response.redirect to keep the URL's friendly, but at the same time, I would like my header and other static elements not refresh each time. Do they use partial page caching to achieve this?

Response.Redirect in AJAX

I have a button in Update panel.

On button click I have written

Response.Redirect("InterMediateMsg.aspx", False)

When I executes the application I got the Error..

Sys.WebForms.PageRequestParserErrorException:The message received from the server could not be parsed.

How should I implement Redirection in AJAX.

Hi,

in the onclick (client side!!) you just place self.location.href='urltogoto'. Don't use AJAX for something like that but plain old javascript.

Grz, Kris.


Response.Redirect should work fine during an async postback. Try dropping the "False"... I'm not sure if you can use that option.


Actually I have performed server side coding( Database operations) on button click .

After the successful operation I want to navigate to another page.

How could I do it.


I have tried it by dropping false.

Actually this second parameter specifies whether I want to terminate execution of current page or not.

Is there any effect of browser.

I am using IE 6.0


Make sure that you have buffer set to false on the page from which you wish to redirect - otherwise output will already have been streamed out to the client, and things will go horribly wrong!

This cost me quite a bit of investigation a while ago..!


i think this error may be because it is trying to process a redirect within the update panel. assuming you use a trigger for the updatepanel and button, set it to a asp:PostBackTrigger instead of a asp:AsyncPostBackTrigger, this will send your page into a full postback, which may solve your problem (i haven't tested it).


I try the way you suggest, and its work !Wink


glad to help!Smile


Thnx ChrisCicc ,

It's working.

I have set the Trigger for button to PostBack and it worked.

Response.Redirect not working while inside an Update Panel

I have a link button inside an update panel. When the user clicks this button, it calls a function that performs a database update and then redirects them to another page. However, Response.Redirect isn't working with AJAX. Any suggestions how I can do this? Thanks!Can you post your code here?

Hi,

Reponse.Redirect works with UpdatePanel. Please refer to this sample:

<%@. 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"> protected void Button1_Click(object sender, EventArgs e) { Response.Redirect("http://www.microsoft.com"); }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

Response.write in Update Panel

Is it possible to use a response.write in an update panel? I have a button converting a datagrid to excel using response.write. The button will work fine outside of the update panel but when I try it inside the update panel I am getting an error.

Try a response.clear

 Response.Clear() Response.AddHeader("content-disposition","attachment; filename=Survey_Results.xls") Response.Charset ="" Response.Cache.SetCacheability(HttpCacheability.NoCache)Dim stringWriterAs System.IO.StringWriter =New System.IO.StringWriter()Dim htmlWriteAs System.Web.UI.HtmlTextWriter =New HtmlTextWriter(stringWriter) stringWriter.Write("Question,Option,Option Type,Is Correct?,UserID" & vbCrLf)Dim colSurveyResultInfoAs List(Of SurveyResultInfo) = SurveyOptionController.GetSurveyResultData(ModuleId)Dim objSurveyResultInfoAs SurveyResultInfoFor Each objSurveyResultInfoIn colSurveyResultInfo stringWriter.Write(objSurveyResultInfo.Question &"," & objSurveyResultInfo.OptionName &"," & objSurveyResultInfo.OptionType &"," & objSurveyResultInfo.IsCorrect &"," & objSurveyResultInfo.UserId & vbCrLf)Next Response.Write(stringWriter.ToString()) Response.Flush() Response.Close()

After a little more research I found the answer.

<Triggers>
<asp:PostBackTrigger ControlID="btnExport" />
</Triggers>

http://ajax.asp.net/docs/mref/T_System_Web_UI_PostBackTrigger.aspx


You can't send a traditional octet stream file response in a partial postback because there isn't an HTTP response coming back to the browser. It's just a string returned to the XmlHTTPRequest.

However, you canuse an iframe to accomplish asynchronous file downloads.

Response.Write inside Updatepanel Beta 2

Hi,

I have a button inside a updatepanel, when the client click the button he can download a PDF. Everything works perfectly outside the update panel but not inside it. I got the next error message:

Sys.Webforms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error is when the response is modified by calls to Response.Write...

I really appreciate any help.

Thanks,

Jaime

My code:

PrivateSub ShowPdf(ByVal strPathAsString)

Response.ContentType =

"application/x-download"

Response.AddHeader(

"Content-Disposition","filename=YourPdf.pdf")

Response.WriteFile(strPath)

Response.End()

End Sub

<%@dotnet.itags.org.PageLanguage="VB"AutoEventWireup="false"CodeFile="Resultados.aspx.vb"Inherits="Resultados" %>

<%@dotnet.itags.org.RegisterAssembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

Namespace="Microsoft.Web.UI"TagPrefix="asp" %>

<%

@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="AjaxToolKit" %>

<!

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">

.............

<

asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate><tablestyle="width: 840px"><tr><tdstyle="width: 762px; height: 153px;"><AjaxToolKit:RoundedCornersExtenderID="RoundedCornersExtender1"runat="server"TargetControlID="TitlePanel1"Radius="10"></AjaxToolKit:RoundedCornersExtender><AjaxToolKit:CollapsiblePanelExtenderID="CollapsiblePanelExtender1"runat="server"Collapsed="true"SuppressPostBack="false"TargetControlID="ContentPanel1"ExpandControlID="Panel1"CollapseControlID="Panel1"imageControlID="image1"ExpandedImage="~/images/collapse_blue.jpg"CollapsedImage="~/images/expand_blue.jpg"></AjaxToolKit:CollapsiblePanelExtender>............

<

asp:PanelID="ContentPanel1"runat="server"CssClass="collapsePanel"Height="0"Width="728px"><tablestyle="width: 728px"><tr><tdstyle="width: 93px; height: 4px"><asp:ButtonID="Button1A"runat="server"Font-Bold="True"Font-Size="X-Small"ForeColor="Crimson"Text="Get Your PDF"Width="224px"/></td>

Hi,

After a while I have found a workaround for the problem I posted, so I am posting this workaround here in case someone else have the same problem:

Basically I have include a second button (button2) outside the control panel. Once the first button (button1, the one inside the updatepanel) is clicked it fire the next javascript:

<input type="submit" name="Button1" value="Button" onclick="javascript:document.getElementById('button2').click() ;" id="Button1" /><br />

So button1 "clicks" button2 (that is the one outside the updatepanel) and this second button is the one that get the PDF file.

To include the javascript you just need to include the next line (in vb) in the "load" of the page:

button1.Attributes.Add(

"onclick","javascript:document.getElementById('button2').click() ;")

Now i am looking for a way to hidde button2 (notice that in order to click it you can not set visible to false).

Hope this can help someone.

Best,

Jaime

Response.Write with update panel issue

I am having a problem with a response.write in page.load and an atlas update panel. I created a quick sample to repro this issue. What should happen is the ddl loads with the current date. If I run it doing a response.write of the stylesheet in the page.load, it does not work. If I put the stylesheet reference at the top of the webform, it works. The page source rendered in IE is exactly the same, however using fiddler I noticed that the Atlas request on the button click returned different results. The main difference is the response.write way returns what I had in the response.write before the delta tags in the fiddler response.

In my codebehind I have:

PartialClass LiveTestInherits System.Web.UI.PageProtected Sub btnClickMe_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles btnClickMe.Click ddlStuff.Items.Add(New ListItem(Date.Now.ToString))End Sub Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.Load Response.Write("<head><link rel=""stylesheet"" type=""text/css"" href="http://links.10026.com/?link="/tools/style0.css""/></head>")End SubEnd Class
Webform
 
<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false" CodeFile="LiveTest.aspx.vb" Inherits="LiveTest" %><!--head><link rel="stylesheet" type="text/css" href="http://links.10026.com/?link=/tools/style0.css"/></head--><head runat="server"> <title>Untitled Page</title></head><atlas:ScriptManager ID="sm" runat="server" EnablePartialRendering="true"></atlas:ScriptManager><body> <form id="form1" runat="server"> <div> <div class="Heading">This is a test</div> <asp:Button ID="btnClickMe" Text="Click Me" runat="server" /> <br /> <atlas:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:DropDownList ID="ddlStuff" runat="server"></asp:DropDownList> </ContentTemplate> <Triggers> <atlas:ControlEventTrigger ControlID="btnClickMe" EventName="Click" /> </Triggers> </atlas:UpdatePanel> </div> </form></body>
Fiddler Views
(Response.Write Does not work)
<head><link rel="stylesheet" type="text/css" href="/tools/style0.css"/></head><delta><rendering><head><title>....</delta>vs.(Declare stylesheet in html works)
<delta><rendering><head><title>Untitled Page</title><style type="text/css">....</delta>

Is there any kind of workaround for this issue (besides don't response.write your stylesheets)? We dynamically write out different stylesheets based on user preferences in a base page that other web pages inherit from.

Thanks in advance

I found that using

Me.Controls.AddAt(0,New System.Web.UI.LiteralControl("<head>....<style>.....</head>"))

Works fine instead of doing the response.write

Thanks

restarting the autocomplete extender?

hi everyone,

I have an autocomplete textbox and detailsview control inside of update panel with partial rendering enabled. When I use the autocomplete control first the time and click on the search button, the detailsview control loads the data and displays it.

But when delete the textbox and start typing again, it no longer autocompletes. Does this work or is there something wrong with my code.

thanks,

gavin

Code Behind

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Lookup : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void ButtonLookup_Click(object sender, EventArgs e)
{
DataSet1TableAdapters.StaffTableAdapter TAStaff = new DataSet1TableAdapters.StaffTableAdapter();

DetailsView.DataSource = TAStaff.GetStaffInfoByName(SearchKey.Text);
DetailsView.DataBind();
DetailsView.Visible = true;
}
}

HTML Page

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Lookup.aspx.cs" Inherits="Lookup" %
<!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 id="Head1" runat="server">
<atlas:ScriptManager runat="server" EnablePartialRendering="true" ID="scriptManager">
</atlas:ScriptManager>
<style type="text/css">
body { font: 11pt Trebuchet MS;
font-color: #000000;
padding-top: 72px;
text-align: center }

.text { font: 8pt Trebuchet MS }
</style>

</head>

<body>
<form id="Form1" action="" runat="server">

<atlas:UpdatePanel ID="Panel2" Mode="Always" runat="server">
<ContentTemplate
<div>
Search for
<asp:TextBox ID="SearchKey" runat="server"></asp:TextBox>
<asp:Button ID="ButtonLookup" runat="server" Text="Lookup" OnClick="ButtonLookup_Click" />

</div>
<hr style='width: 300px'/
<asp:DetailsView ID="DetailsView" runat="server" Height="196px" Width="323px">
</asp:DetailsView>
</ContentTemplate>
</atlas:UpdatePanel
</form>

<div id="completionList"></div>
<div>
<span id="Results">Here's some other text that shouldn't refresh.</span></div
<script type="text/javascript">
function DoSearch()
{
var SrchElem = document.getElementById("SearchKey");
Samples.AspNet.HelloWorldService.HelloWorld(SrchElem.value,
OnRequestComplete);
}

function OnRequestComplete(result)
{
var RsltElem = document.getElementById("Results");
RsltElem.innerHTML = result;
}

</script
<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<textBox id="SearchKey">
<behaviors>
<autoComplete
completionList="completionList"
serviceURL="AutoCompleteService.asmx"
serviceMethod="GetWordList"
minimumPrefixLength="1"
completionSetCount="15"
completionInterval="500" />
</behaviors>
</textBox>
</components>
</page>
</script>
</body>
</htmlHi gfun,

The AutoCompleteExtender isn't part of the Toolkit, so you'll have better luck asking this question in theAJAX UI forum.

Thanks,
Ted

Restore position of a modal panel after postback

There is a modal panel which was created with the help of a modalPopupExtender. There is also an updatePanel and a GridView on it. Selecting a row in the GridView raises postback what sets the position of modal panel to default value (center of the screen). How to restore position at the moment of postback?

Hi,

According to your problem, I think you may keep the position of the modalPopup in two hiddenfileds outside UpdatePanelbefore postback, and set the popup's position to those values in hiddenFields inendRequest event handler.

For instance:

function beginRequestHandler()
{
$get("hfX").value = $find('behaviorIDOfModalPopup').get_X();
$get("hfY").value = $find('behaviorIDOfModalPopup').get_Y();
}

function endRequestHandler()
{
$find('behaviorIDOfModalPopup').set_X($get("hfX").value);
$find('behaviorIDOfModalPopup').set_Y($get("hfY").value);
}

Hope this helps.


Thanks,

There is one more solution:

function BeginRequest(sender, args) { var s = $get('Panel1').style.left; $find('ModalPopupExtender1').set_X(s.substring(0, s.length - 2)); s = $get('Panel1').style.top; $find('ModalPopupExtender1').set_Y(s.substring(0, s.length - 2)); }