Showing posts with label back. Show all posts
Showing posts with label back. Show all posts

Wednesday, March 28, 2012

Posting Back From Client

Hello,

I have a question about posting back from the client. How do I cause an update panel to update from the client? What I want to do is pop up another window, do some things on it, and have it update a gridview on the page that opened the window. I'm assuming I can do this with javascript. Can anyone point me in the right direction?

Thanks,

Nick

Anyone have any suggestions?

Monday, March 26, 2012

prevent asp:ImageButton from refreshing image...

Is there a way (with the Dec release) to prevent the image in an image button from refreshing when posting back to the server in an UpdatePanel?

It would seem to defeat the purpose of Ajax to have this image refresh all the time during a post to the server...

Wade.

The idea would be to keep the image button outside the updatepanel so it is not refreshed when the page is posted back.

- Kashif


Actually the behavior is browser dependent. Internet Explorer seems to refresh images by trying to go to reload the image, while Mozilla seems to cache images completely locally and without that funky flash.

In IE if you replace content that contains images references (as UpdatePanel will do) all the images reload. Usually they will come from Cache so it's pretty fast, but there's still some amount of flash. If you use FireFox you don't get that flash. You can hook up Fiddler or other HTTP proxy to see this behavior.

Certainly makes for smoother operation of any sort of callback in FireFox.

+++ Rick --


The best method is to have a script manager control on the page with 'Enable Partial Rendering' set to 'True', and then only put the parts of your page that would be updated on a page refresh within the UpdatePanel controls.

So if you don't want the image to 'blink', it's best to leave it outside of that control.


This is a problem that is currently driving me nuts. I have a large UpdatePanel that has a tab control on it. The tabs are painted using image backgrounds defined in a stylesheet. In IE, using Nikhil's web dev tool, I can see that for every tab all the images are requested and the server responds with code 200. It's like IE's local cache is completely ignored. This is causing an ugly flicker and some repaint issues. I've tried the max-age cache control-cache extension but it doesn't seem to work. I found the best information athttp://aspnetresources.com/blog/cache_control_extensions.aspx.

Does anyboy have any ideas?

This bug is going to kill me too. all the images on the page even those are outside the updatepanel and wrote with <img> tag are flikering too.

Any solution to resolve this problem?


The image flicker has nothing to do with ATLAS - it's an IE bug - IE is refreshing the images when it shouldn't. You can fix that by changing your IE cache settings. I think it happens if you have your cache set to refresh on every page hit. IE apparently considers the partial XmlHttp postback as a page refresh and refreshes all content in the page. Put IE back to auto caching and the flickering should stop.

+++ Rick --


Dear Rick

Thanks For Comment

My IE Caching was set to Auto Already, and here still the killer bug.

Any other Idea?

H.B.F


Hello. This is a bug in IE when it's pulling in background images defined in CSS. As far as I am aware, the solution lies within IIS. Have a read of this: http://erik.eae.net/archives/2007/02/26/13.13.48/

cheers
Anthony

Saturday, March 24, 2012

Problem Dragging ModalPopupExtender

In the ModalPopupExtender when I drag the popup it always snaps back to the middle.

If I place the JavaScript code that is in the sample page on my page then I am able to drag the popup around the page and it stays where I drop it as expected.

<script type="text/javascript"> // The following snippet works around a problem where FloatingBehavior // doesn't allow drops outside the "content area" of the page - where "content // area" is a little unusual for our sample web pages due to their use of CSS // for layout. function setBodyHeightToContentHeight() { document.body.style.height = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight) + "px"; } setBodyHeightToContentHeight(); $addHandler(window, "resize", setBodyHeightToContentHeight); </script>

The JavaScript says it's just a work around due to how the sample page is structured. But, in my page I'm not using any type of css layout (other than for the ModalPopupExtender background). I just have a HyperLink, Panel for the popup, Panel for the popup handle and ModalPopupExtender.

<%@dotnet.itags.org. Page Language="C#" %><%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!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 ButtonOK_Click(object sender, EventArgs e){Response.Redirect("myModal.aspx");}</script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title>Untitled Page</title><style type="text/css">/*Modal Popup*/.modalBackground{background-color: #000000;filter: alpha(opacity=30);opacity: 0.3;}</style></head><body><form id="form1" runat="server"><div><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:HyperLink ID="LinkShow" runat="server">Click to show dialog</asp:HyperLink><br /><br /><br /><asp:Panel ID="PanelPopup" runat="server"><asp:Panel ID="PanelPopupHandle" runat="server">This is the popup handle</asp:Panel>This is the content of the popup panel<br /><asp:Button ID="ButtonOK" runat="server" Text="OK" onclick="ButtonOK_Click" /><asp:Button ID="ButtonCancel" runat="server" Text="Cancel" /></asp:Panel><br /><cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="modalBackground"TargetControlID="LinkShow" CancelControlID="ButtonCancel" Drag="True" PopupControlID="PanelPopup"PopupDragHandleControlID="PanelPopupHandle"></cc1:ModalPopupExtender></div></form></body></html>

Am I missing something or do I need to always place that piece of JavaScript on pages that use the ModalPopupExtender?

this is problem due to not specifying height and width for popup panel
try adding height and width:-

<asp:PanelID="PanelPopup"runat="server"Width="300"Height="300"BorderWidth="1"BackColor="AliceBlue">


Yes, that works. Thank you!


As soon as I click on the dragable header of the ModalPopupExtender popup, the panel moves to the right. It keeps doing this every time I click on it.

I have read every work around on the web to fix this and nothing has worked for me:

1. Added the javascriptsetBodyHeightToContentHeight()

2. Set the Height and Width of the body tag

3. Modified FloatingBahavior.js:

this.onDragEnd =function(canceled) {

canceled =false; <-- added this

4. Set the width and height in the last post.

Nothing has worked for me! Even setting Drag="true" or Drag="false" seems to not work at all.

I could sure use an answer.

Wednesday, March 21, 2012

Problem loading saved data back into dropdownlist

I'm completely new to ASP.NET and Ajax, having quickly inherited a project from a consultant who is no longer with us.

Have a form with C# codebehind, and all this is running inside some Ajax components (tabcontainer and update panels). One dropdownlist (SystemID) determines the filtered values in a second dropdownlist (TypeID). In the page, there's the following to determine the source for each list:

<asp:SqlDataSourceID="sqlSystem"runat="server"

SelectCommand="Select Distinct '0' As SystemID, '(Select)' As Description From CMSSystem UNION

Select SystemID,Description From CMSSystem Where Active='1'">

</asp:SqlDataSource>

<asp:SqlDataSourceID="sqlType"runat="server"

SelectCommand="Select Distinct '0' As TypeID, '(Select)' As Description From CMSType UNION

Select TypeID, Description from CMSType Where SystemID = @dotnet.itags.org.SystemID">

<SelectParameters>

<asp:ControlParameterControlID="cboSystem"Name="SystemID"PropertyName="SelectedValue"/>

</SelectParameters>

</asp:SqlDataSource>

When I complete an empty form, the linking between the lists is fine. Select a value from SystemID, then I can select a value from TypeID that has been filtered.

The problem is on trying to load existing data. I have a procedure call inside Page_Load that loads existing values onto the form. Text boxes and checkboxes are just fine, and standalone dropdownlists are fine. I can load SystemID from a dataset row, but when I try to do the same for TypeID (trying to lookup the saved value in the list of filtered items), I find that the items collection is completely empty - and therefore, I get a null selectedvalue. What I'm guessing is that the SqlDataSource isn't "firing" (?) for the TypeID for some reason at the time of Page_Load, so I have no data to bind to the control.

Is that a good assumption, and if so, how can I get around this? I've been floundering around for a couple of weeks with this, and need any assistance I can get.

How about using the Page's Prerender event for that, instead of Load? Alternatively, you could handle theSqlDataSource's Selected event.


Didn't see any change with Page_PreRender instead of Page_Load.

I have this hunch that the SqlDataSource isn't being re-evaluated when I manually set the first dropdownlist's SelectedIndex (based on the previously saved, now retrieved, data). It must be a matter of timing or something. Trying to execute this codebehind:

if (dsRequestDetails.Tables[0].Rows[0]["SystemID"].ToString() !="")

{

liFind = cboSystem.Items.FindByValue(dsRequestDetails.Tables[0].Rows[0]["SystemID"].ToString());

cboSystem.SelectedIndex = cboSystem.Items.IndexOf(liFind);

}

if (dsRequestDetails.Tables[0].Rows[0]["TypeID"].ToString() !="")

{

liFind = cboType.Items.FindByValue(dsRequestDetails.Tables[0].Rows[0]["TypeID"].ToString());

cboType.SelectedIndex = cboType.Items.IndexOf(liFind);

}


populate the second dropdown at the ondatabound event of the first drop down. This will solve your problem