|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Postback problem with web partsIs there anyway to prevent a postback event when a web part is moved into a
different zone? I am using the MSNBC weather web part and it fires a java script which is causing an error because the page is posting back. Thanks in advance, Vince Vince,
I see you've spent two days on this. Tell us what the error is and maybe someone in the group can help fix the error instead of preventing the postback. In the mean time I know a great deal about web parts maybe I'll check out this msnbc webpart and try to duplicate the error for you. What url did you download the webpart from? Good Luck DWS Show quoteHide quote "Vince Varallo" wrote: > Is there anyway to prevent a postback event when a web part is moved into a > different zone? I am using the MSNBC weather web part and it fires a java > script which is causing an error because the page is posting back. > > Thanks in advance, > Vince OK, here is the code,
Default.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register Src="Weather.ascx" TagName="Weather" TagPrefix="uc1" %> <!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> </head> <body> <form id="form1" runat="server"> <div> <asp:WebPartManager ID="WebPartManager1" runat="server"> </asp:WebPartManager> <table style="width: 100%; height: 100%"> <tr> <td style="width: 72px"> <asp:WebPartZone ID="WebPartZone1" runat="server" Height="576px" Width="282px"> <ZoneTemplate> <uc1:Weather ID="Weather1" runat="server" title="Weather" /> </ZoneTemplate> </asp:WebPartZone> </td> <td style="width: 100px"> <asp:WebPartZone ID="WebPartZone2" runat="server" Height="551px" Width="303px"> </asp:WebPartZone> </td> <td style="width: 100px"> <asp:WebPartZone ID="WebPartZone3" runat="server" Height="557px" Width="288px"> </asp:WebPartZone> </td> </tr> </table> </div> </form> </body> </html> Default.aspx.cs using System; using System.Data; using System.Configuration; 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 _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } void Page_Init(object sender, EventArgs e) { WebPartManager1.DisplayMode = WebPartManager.DesignDisplayMode; } } Then i have the weather part in a user control. Weather.ascx <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Weather.ascx.cs" Inherits="Weather" %> <a href="javascript:WeatherPers();">Change Location</a> <div id="msnbcWea_WPQ_" _locID="L_Loading_Text">This webpart requires Microsoft Internet Explorer 5.0 or higher</div> <script id="msnbcWeaData_WPQ_" language="javascript"></script> <script id="msnbcWeaRend_WPQ_" language="javascript" src="http://www.msnbc.com/m/chnk/r/weather_r_src.js"></script> <script id="msnbcWeaMain_WPQ_" language="javascript" src="http://www.msnbc.com/m/dd/wea_dd_m_src.asp?uid=_WPQ_"></script> Then run the project and drag the weather part from zone 1 to zone 2. Then drag it from zone 2 to zone 3. This is when the error occurs in the java script. It is in the WeatherMain() javascript which is coming from msnbc. oDiv.style.padding = ... Thanks, Vince Show quoteHide quote "DWS" wrote: > Vince, > I see you've spent two days on this. Tell us what the error is and maybe > someone in the group can help fix the error instead of preventing the > postback. In the mean time I know a great deal about web parts maybe I'll > check out this msnbc webpart and try to duplicate the error for you. What > url did you download the webpart from? > > Good Luck > DWS > > "Vince Varallo" wrote: > > > Is there anyway to prevent a postback event when a web part is moved into a > > different zone? I am using the MSNBC weather web part and it fires a java > > script which is causing an error because the page is posting back. > > > > Thanks in advance, > > Vince Vince,
Sorry I took so long. I have a work around. Basicly what I'm doing is surrounding the control and with a panel and setting the visibility false when the page displaymode allows design. You could expand this with a label or something that says "MSNBC Weather is not available in design mode". Partial Class ctrlmsnbc Inherits System.Web.UI.UserControl Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender Try pnlwebpart.Visible = Not WebPartManager.GetCurrentWebPartManager(Page).DisplayMode.AllowPageDesign Catch ex As Exception End Try End Sub End Class <%@ Control Language="VB" AutoEventWireup="false" CodeFile="ctrlmsnbc.ascx.vb" Inherits="ctrlmsnbc" %> <asp:Panel runat="server" ID="pnlwebpart"> <a href="javascript:WeatherPers();">Change Location</a> <div id="msnbcWea_WPQ_" _locID="L_Loading_Text">This webpart requires Microsoft Internet Explorer 5.0 or higher</div> <script id="msnbcWeaData_WPQ_" language="javascript"></script> <script id="msnbcWeaRend_WPQ_" language="javascript" src="http://www.msnbc.com/m/chnk/r/weather_r_src.js"></script> <script id="msnbcWeaMain_WPQ_" language="javascript" src="http://www.msnbc.com/m/dd/wea_dd_m_src.asp?uid=_WPQ_"></script> </asp:Panel> Good Luck DWS Show quoteHide quote "Vince Varallo" wrote: > Is there anyway to prevent a postback event when a web part is moved into a > different zone? I am using the MSNBC weather web part and it fires a java > script which is causing an error because the page is posting back. > > Thanks in advance, > Vince
ASP.NET 2.0 Dropdownlist EnableViewState=false SelectedIndexChange
GridView ASP 2.0 DropDownList: MaxDropDownItems? HELP: Dynamic updateable checkbox list Convert string to ITemplate Treeview update on postback GridView current row?? Retrieving machine.config/web.config values ... asp:treeview, expand, index of node Go directly to edit mode in formview? |
|||||||||||||||||||||||