Showing posts with label bound. Show all posts
Showing posts with label bound. Show all posts

Monday, March 26, 2012

Call the method bound to an linkbutton after ajax callback

Hi everybody

I just have the following problem:

I created a ASP-LinkButton and added a method in the code-behind file for its onclick event. Then I added a break point at the beginning of the method to check if it's called.

Now I added a JS which calls the __doPostback("xxx", ""); exactly like the LinkButton does and everything works fine.

Now I add a Webservice, which validates my input and if everything works fine, its callback should call the click method of the asp-button. Guess what happens: the postback is called, but not the event of the button. If I do this before outside the callback - everything works fine, so I know the code is correct.

I even tried to add a "window.setInterval" timer which always checks a bool and calls the postback as soon as the bool is turned to true ... Then I set the bool after the callback and guess again: The postback is called but not the method ...

I don't have any further ideas for workarounds - anyone got a hint for me?

THANKS!

Hi,

Now I get a general idea of your situation. But your description doesn't give me sufficient information to find the cause.

Accordingly, I made a sample, please try it.

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %><!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:ScriptManager ID="ScriptManager1" runat="server"> <Services><asp:ServiceReference Path="WebService.asmx" InlineScript="true" /> </Services> </asp:ScriptManager> <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton></div> </form> <script type="text/javascript"> var count = 0; function callBack(result) { if(result) __doPostBack('LinkButton1',''); } function callWS() { count++; WebService.ShouldCallBack(count, callBack); } window.setInterval(callWS, 2000); </script></body></html>
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 partialclass Default3 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) { }protected void LinkButton1_Click(object sender, EventArgs e) { Response.Write("Linkbutton is clicked on " + DateTime.Now.ToString()); }}

<%@. WebService Language="C#" Class="WebService" %>using System;using System.Web;using System.Web.Services;using System.Web.Services.Protocols;[WebService(Namespace = "http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][System.Web.Script.Services.ScriptService]public class WebService : System.Web.Services.WebService { [WebMethod] public bool ShouldCallBack(int count) { return count == 5; } }
Hope this helps.

Wednesday, March 21, 2012

CalendarExtender rendering on a page with a large TabContainer

Very strange issue here. I have a page with embedded Tabcontainers and a CalendarExtender. When I click on the Textbox bound to the CalendarExtender it does not display properly. I get no forward/back arrows to scroll months, and if I click on the month name, panels start flying around as opposed to the scrolling behavior that should be experienced.

I've been gradually removing items from my page to try to isloate the problem, and have trimmed things to the attached file. From here, if I delete any one of the TabPanel items, the calendar will render properly. Put it back, and it's messed up again. Additionally, if I move the CalendarExtender above the TabPanel, it renders properly as well. This won't work for my solution, however.

Any insight on what is causing the problem?

/* test.aspx ******************************************************/

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="info_test" Title="Untitled Page" %>
<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@dotnet.itags.org. Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>

<!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">
<title>Test</title>
</head>
<body >
<form runat="server" id="frmMP" >
<asp:ScriptManager ID="scmMain" EnablePartialRendering="true" runat="server" />
<ajax:tabcontainer runat="server" ID="tbcMain">
<ajax:TabPanel runat="server" ID="tplMain1" HeaderText="Main1" >
<ContentTemplate>
<ajax:tabcontainer ID="tplSub1" runat="server">
<ajax:TabPanel runat="server" ID="tplSub1_1" HeaderText="Sub1_1"/>
<ajax:TabPanel runat="server" ID="tplSub1_2" HeaderText="Sub1_2"/>
<ajax:TabPanel runat="server" ID="tplSub1_3" HeaderText="Sub1_3"/>
<ajax:TabPanel runat="server" ID="tplSub1_4" HeaderText="Sub1_4"/>
<ajax:TabPanel runat="server" ID="tplSub1_5" HeaderText="Sub1_5"/>
<ajax:TabPanel runat="server" ID="tplSub1_6" HeaderText="Sub1_6"/>
<ajax:TabPanel runat="server" ID="tplSub1_7" HeaderText="Sub1_7"/>
</ajax:tabcontainer >
</ContentTemplate>
</ajax:TabPanel>
<ajax:TabPanel runat="server" ID="tplMain3" HeaderText="Main3">
<ContentTemplate>
<ajax:tabcontainer ID="tplSub3" runat="server">
<ajax:TabPanel runat="server" ID="tplSub3_1" HeaderText="Sub3_1" />
<ajax:TabPanel runat="server" ID="tplSub3_2" HeaderText="Sub3_2" />
<ajax:TabPanel runat="server" ID="tplSub3_3" HeaderText="Sub3_3" />
<ajax:TabPanel runat="server" ID="tplSub3_4" HeaderText="Sub3_4" />
<ajax:TabPanel runat="server" ID="tplSub3_5" HeaderText="Sub3_5" />
<ajax:TabPanel runat="server" ID="tplSub3_6" HeaderText="Sub3_6" />
</ajax:tabcontainer >
</ContentTemplate>
</ajax:TabPanel>
<ajax:TabPanel runat="server" ID="tplMain4" HeaderText="Main4">
<ContentTemplate>
<ajax:tabcontainer ID="tplSub4" runat="server">
<ajax:TabPanel runat="server" ID="tplSub4_1" HeaderText="Sub4_1" />
<ajax:TabPanel runat="server" ID="tplSub4_2" HeaderText="Sub4_2" />
<ajax:TabPanel runat="server" ID="tplSub4_3" HeaderText="Sub4_3" />
<ajax:TabPanel runat="server" ID="tplSub4_4" HeaderText="Sub4_4" />
<ajax:TabPanel runat="server" ID="tplSub4_5" HeaderText="Sub4_5" />
<ajax:TabPanel runat="server" ID="tplSub4_6" HeaderText="Sub4_6" />
<ajax:TabPanel runat="server" ID="tplSub4_7" HeaderText="Sub4_7" />
<ajax:TabPanel runat="server" ID="tplSub4_8" HeaderText="Sub4_8" />
<ajax:TabPanel runat="server" ID="tplSub4_9" HeaderText="Sub4_9" />
<ajax:TabPanel runat="server" ID="tplSub4_10" HeaderText="Sub4_10" />
<ajax:TabPanel runat="server" ID="tplSub4_11" HeaderText="Sub4_11" />
</ajax:tabcontainer >
</ContentTemplate>
</ajax:TabPanel>
</ajax:tabcontainer>
<asp:TextBox ID="txtA" runat="server"/>
<ajax:CalendarExtender ID="ceCal" runat="server" TargetControlID="txtA" CssClass="MyCalendar"/>
</form>
</body>
</html>

Hi,

Wow... this is bizarre. Our current best guess is that it looks like IE will only load the first 32 <link> tags at the top of the page. Currently if you use the default tab style, it's adding a <link> for each tab/panel/etc. and the <link> for the Calendar's style is the 33rd (which is why moving the calendar above the tabs fixes the problem). As a quick workaround I'd recommend you not use the default style (i.e. copy the default style into your page, give it a different name, etc.) to prevent tabs from loading that many links. I'll open a work item to see what we can do from our end to not load duplicate <link>s.

Thanks,
Ted


Hi,

Here's thework item.

Also, there's an even quicker work around. Just move the CalendarExtender above the tabs. Your textbox can stay in the same place so your page looks fine, but the Calendar will be processed first.

Thanks,
Ted


Workaround works perfectly. Thanks for your assistance, Ted!

Yes