Showing posts with label event. Show all posts
Showing posts with label event. Show all posts

Wednesday, March 28, 2012

Page.Redirect From Control Event Using Atlas

I am a newbie in atlas..just a couple of hour of experience.

I've managed to create a simple project with sucess, and all works well. But, in a certain event of an treeview control, the "SelectedNodeChanged", i need to redirect the page to another URL. The Page.Redirect runs it the server, but the page doesn't do the postback. How can i force the postback, in a certain event?

Thank you very much.

Well...i found out that the Page.Redirect in Atlas doesn't work very well.

I've got this solution, it's not the best way to do this, but it works,

Page.ClientScript.RegisterStartupScript(this.GetType(),"redirect",@."window.location.href='default.aspx';",true)

PageError event of scriptmanager not firing

I have a content page that has a master page. I have an updatepanel and a scriptmanger in my content page. I defined a handler for OnPageError for the scriptmanager and defined a error template for the scriptmanager but when I set the e.errormessage in the OnPageError event, but if I set a break point in the event, the break point is never reached and the error message in the template still displays 'unknown error' Any ideas?

if I put a button on the page and in the click event of the button i manually throw and error.

thrownewException("error button clicked");

the event fires and works fine.

but if I put some invalid characters like '<img src' inside a textbox and then click the button (removing the throw) then the OnPageError isn't fired

PageError doesnt preserve stack trace

Hi,

I use the ScriptManager.PageError event in order to catch internal exceptions and rethrow them to be handled by the Application_Error event, just like in any non-ATLAS page.

The problem is that ATLAS clears the exception's stack trace and restarts it only from the PageError event handler itself.

I'm having hard time resolving the problems without having the original stack trace.

Any ideas?

Thanks,

Lior

hello.

are you sure about this? i seem to recall cehcking for a stack of an exception during the error handling...i maybe wrong since i don't have atlas installed here and can't check it right now...


Yes, I created an exception inside a function of a UserControl I'm using in my page, and this is the stack trace of the e.Error exception returned by theScriptManager_PageError event.

As you can see, there is no stack trace before the PageError event. When not using ATLAS, the Server.GetLastError() function returns the original exception with the original stack trace as an InnerException.

at ***.Web.UI.***.TheScriptManager_PageError(Object sender, PageErrorEventArgs e) in ****.aspx.cs:line 179

at Microsoft.Web.UI.ScriptManager.OnPageError(PageErrorEventArgs e)

at Microsoft.Web.UI.ScriptManager.OnPageError(Exception ex)

at Microsoft.Web.UI.ScriptManager.OnPageError(Object sender, EventArgs e)

at System.Web.UI.TemplateControl.OnError(EventArgs e)

at System.Web.UI.Page.HandleError(Exception e)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Lior


hello.

hum...here's an excerpt of a stack trace from an aspx on the error event of the scriptmanager:

at ASP.error.h(Object sender, EventArgs args) in d:\atlas\AtlasWebSite2\error.ascx:line 7
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

as you can see, the error comes from an usercontrol which is inside an updatepanel,...


Hi,

My mistake. I did a "throw e.Error" in the PageError handler which, of curse, cleared the stack trace...

Thanks for your help,

Lior


I have the same problem in my page, but your post don't solve my problem. I did the same thing you did and rethrow the exception e.Error in the Script Manager PageError event hadler but the exception is again catched by the atlas framwork not by the application error handler and a popup window shows with the exception. Why is this happening?

hello.

well, if i recall correctly, scriptmanager catches all page erros and removes them so that the current request can be handled correctly. if it didn't do this, the client side would never receive the correct response (ie, the response wouldn't be in the correct format). if you need to log the error on the server, then handle the scriptmanager pageerror event and perform the loggin there. instead of showing the popup with the error, you can build your own error template which will be shown to the user in those cases...


No this is not what I need. The problem is this: when an exception is thrown i my atlas page inside an update panel a javascript win pops up with an message "Unhadled exception". I don't want that! I want that exception to be catch from a httpHandler that uses the Server.GetLastError() method and shows a message in the ErrorPage.aspx. This is it. How can I do that?

I tried to do this like it is said in previous posts

ScriptManager1.PageError += new Microsoft.Web.UI.PageErrorEventHandler(sm_PageError);

protected void sm_PageError(object sender, Microsoft.Web.UI.PageErrorEventArgs e) {
throw e.Error;
}

but it doesn't work.


I'm sorry the mistake was in my code. :)

pageLoaded event

I have created an ASP.NET custom server control that is updated using AJAX via an UpdatePanel using the Tick event of a Timer control as the asyc trigger. I need to execute javascript each time a partial postback returns so I am using the pageLoaded event. This works perfectly in IE7 but doesn't fire in Firefox 2.0.0.3 or Opera 9. On other browsers it never fires the pageLoaded event, but it does the AJAX updating and other javascript works. I am registering the client code during my control's render method.. I have also tried using the endRequest event. Please help. Why won't it work on other browsers.

Below is the rendered HTML:<!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><title>Untitled Page</title><meta content="text/html;charset=iso-8859-1" http-equiv="content-type" /><meta content="NO-CACHE" http-equiv="PRAGMA" /><meta content="NO-CACHE" http-equiv="CACHE-CONTROL" /><meta content="0" http-equiv="EXPIRES" /><style type='text/css'> a.info:active{z-index:0; position:relative; background-color:#FFF647} a.info label{display: none} a.info:active label{ display:inline; position:absolute; white-space:normal; text-wrap:normal; word-wrap:break-word; left:label.parent.width; top:label.parent.height; width:250px; border:1px solid #91907C; background-color:#EAE7C6; z-index:-1; } </style> </head><body> <form name="form1" method="post" action="Default.aspx" id="form1"><div><input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /><input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /><input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEwMzQxMTA4OTkPZBYCAgMPZBYCAgEPZBYCAgIPZBYCZg9kFgJmDxYGHgtjZWxscGFkZGluZwUBMB4LY2VsbHNwYWNpbmcFATAeBXN0eWxlBSlwYWRkaW5nOjVweDt6LWluZGV4OjIwO3Bvc2l0aW9uOmFic29sdXRlO2RkMUSTfpjSwghJETl9/Jgkha9oZaA=" /></div><script type="text/javascript"><!--var theForm = document.forms['form1'];if (!theForm) { theForm = document.form1;}function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); }}// --></script><script src="/WebResource.axd?d=9DvoInn8tlftzCiBPvQagg2&t=632974035101093750" type="text/javascript"></script><script src="/ScriptResource.axd?d=WAnysv6JNp-Tgl_8AndGJnGXdfOUUPdccvGwkhkSJu2uP8RLi_go1jCrdTe0jCpJF0u8GYhfCflHcjQdOJTaXMeB6qn3C9aitPrPuScmgSM1&t=633063657262888841" type="text/javascript"></script><script src="/ScriptResource.axd?d=WAnysv6JNp-Tgl_8AndGJnGXdfOUUPdccvGwkhkSJu2uP8RLi_go1jCrdTe0jCpJF0u8GYhfCflHcjQdOJTaXOmCYkHGf_k8diSD9UcMEoc1&t=633063657262888841" type="text/javascript"></script><script src="/ScriptResource.axd?d=WAnysv6JNp-Tgl_8AndGJnGXdfOUUPdccvGwkhkSJu2uP8RLi_go1jCrdTe0jCpJF0u8GYhfCflHcjQdOJTaXLsHgXZk2LxHv8oSN-rIGKs1&t=633063657262888841" type="text/javascript"></script> <span id="events" style="font-size:Small;"><span id="events_timer1" style="visibility:hidden;display:none;"></span><input name="events$ctl00" type="hidden" id="events_ctl00" /><div id="events_UpdatePanel1"><table cellpadding="0" cellspacing="0" style="padding:5px;z-index:20;position:absolute;"><tr><td rowspan="2" style="border-bottom-style:None;border-bottom-color:#91907C;border-bottom-width:thin;padding-bottom:5px;padding-top:5px;"><img src="../images/greenshd.gif" alt="The IT Road Show.........................." /></td><td style="padding-left:5px;">Tuesday 24 Apr</td><td style="padding-left:15px;">3:30 pm</td></tr><tr><td colspan="2" style="border-bottom-style:None;border-bottom-color:#91907C;border-bottom-width:thin;padding-left:5px;padding-bottom:5px;"><a href="http://www.nova100.com.au" id="events_3160" EventsEventDatesId="3160" LabelId="events_label_0_3160" onfocus="document.getElementById('events_ctl00').value = this.LabelId" onblur="document.getElementById('events_ctl00').value = ''" class="info">The IT Road Show.......................... </a></td></tr><tr><td rowspan="2" style="border-bottom-style:None;border-bottom-color:#91907C;border-bottom-width:thin;padding-bottom:5px;padding-top:5px;"><img src="../images/AKMAL_OVER.gif" alt="The Akmal Show" /></td><td style="padding-left:5px;">Tuesday 24 Apr</td><td style="padding-left:15px;">4:00 pm</td></tr><tr><td colspan="2" style="border-bottom-style:None;border-bottom-color:#91907C;border-bottom-width:thin;padding-left:5px;padding-bottom:5px;"><a href="#" id="events_2749" EventsEventDatesId="2749" LabelId="events_label_1_2749" onfocus="document.getElementById('events_ctl00').value = this.LabelId" onblur="document.getElementById('events_ctl00').value = ''" class="info">The Akmal Show <label id="events_label_1_2749" style="text-decoration:none;">The Akmal Show with Kate Richie Weekdays 4pm-6pm.Akmal was born in Egypt - then moved to Australia. Akmal's mum doesn't think he's that funny - now the rest of Australia think he's ha haa hilarious.</label></a></td></tr><tr><td rowspan="2" style="border-bottom-style:None;border-bottom-color:#91907C;border-bottom-width:thin;padding-bottom:5px;padding-top:5px;"><img src="../images/greenshd.gif" alt="The IT Road Show.........................." /></td><td style="padding-left:5px;">Wednesday 25 Apr</td><td style="padding-left:15px;">3:30 pm</td></tr><tr><td colspan="2" style="border-bottom-style:None;border-bottom-color:#91907C;border-bottom-width:thin;padding-left:5px;padding-bottom:5px;"><a href="http://www.nova100.com.au" id="events_3161" EventsEventDatesId="3161" LabelId="events_label_2_3161" onfocus="document.getElementById('events_ctl00').value = this.LabelId" onblur="document.getElementById('events_ctl00').value = ''" class="info">The IT Road Show.......................... </a></td></tr><tr><td rowspan="2" style="border-bottom-style:None;border-bottom-color:#91907C;border-bottom-width:thin;padding-bottom:5px;padding-top:5px;"><img src="../images/AKMAL_OVER.gif" alt="The Akmal Show" /></td><td style="padding-left:5px;">Wednesday 25 Apr</td><td style="padding-left:15px;">4:00 pm</td></tr><tr><td colspan="2" style="border-bottom-style:None;border-bottom-color:#91907C;border-bottom-width:thin;padding-left:5px;padding-bottom:5px;"><a href="#" id="events_2750" EventsEventDatesId="2750" LabelId="events_label_3_2750" onfocus="document.getElementById('events_ctl00').value = this.LabelId" onblur="document.getElementById('events_ctl00').value = ''" class="info">The Akmal Show <label id="events_label_3_2750" style="text-decoration:none;">The Akmal Show with Kate Richie Weekdays 4pm-6pm.Akmal was born in Egypt - then moved to Australia. Akmal's mum doesn't think he's that funny - now the rest of Australia think he's ha haa hilarious.</label></a></td></tr><tr><td rowspan="2" style="padding-bottom:5px;padding-top:5px;"><img src="../images/redshd.gif" alt="test add 25" /></td><td style="padding-left:5px;">Thursday 26 Apr</td><td style="padding-left:15px;">2:29 pm</td></tr><tr><td colspan="2" style="padding-left:5px;padding-bottom:5px;"><a href="k" id="events_136" EventsEventDatesId="136" LabelId="events_label_4_136" onfocus="document.getElementById('events_ctl00').value = this.LabelId" onblur="document.getElementById('events_ctl00').value = ''" class="info">test add 25 </a></td></tr></table></div></span> <script type="text/javascript">//<![CDATA[Sys.WebForms.PageRequestManager._initialize('ctl06', document.getElementById('form1'));Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tevents$UpdatePanel1'], ['events','events$timer1'], [], 90);//]]></script><script type="text/javascript"><!--Sys.Application.add_init(function() { $create(Sys.UI._Timer, {"enabled":true,"interval":1000,"uniqueID":"events$timer1"}, null, null, $get("events_timer1"));}); Type.registerNamespace('EventsManager'); var prm = Sys.WebForms.PageRequestManager.getInstance(); if (prm != null) { prm.add_endRequest(pageLoadedHandler); } function window.onload() { } function pageLoadedHandler(sender, args) { var hidden = document.getElementById('events_ctl00'); if (hidden != null) { var labelId = hidden.value; if (labelId.length > 0) { var lbl = document.getElementById(labelId); if (lbl != null) { lbl.parentElement.setActive(); } } } } Sys.Application.initialize();// --></script></form> </body></html>

Below is my code for the Render method when I used the endRequest event:

protected override void Render(HtmlTextWriter writer) {base.Render(writer);//Add script and register it. Page.ClientScript.RegisterStartupScript(typeof(EventsManager),"script", @dotnet.itags.org." Type.registerNamespace('EventsManager'); var prm = Sys.WebForms.PageRequestManager.getInstance(); if (prm != null) { prm.add_endRequest(pageLoadedHandler); } function window.onload() { } function pageLoadedHandler(sender, args) { var hidden = document.getElementById('" + ClickedLinkLabelId.ClientID + @dotnet.itags.org."'); if (hidden != null) { var labelId = hidden.value; if (labelId.length > 0) { var lbl = document.getElementById(labelId); if (lbl != null) { lbl.parentElement.setActive(); } } } } ",true); }

Hi,

Can you show me a stripped version of your control and a sample page using it?

It will be easier for us to trouble shooting. Thanks.


Hi Raymond,

I really appreciate your offer of help, but I just figured out what the problem was.

My javascript code below was causing a problem for all the code in my script block on all browsers apart from IE.

Problem code:

function window.onload()
{

}

When I changed it to the code below, it worked in all browsers.

Correct code:

window.onload = function()
{
document.getElementById('" + TimeZoneOffset.ClientID + @."').value = -(new Date().getTimezoneOffset());
}

Thanks again.

pageLoad() javascript function

I understand that a script with the pageLoad() function is a way to hook into the client side load event.

That works great if you are working in the .aspx page itself. What if you're in a user control and want something to hook into the pageLoad() event on the client?

I could use Page.RegisterClientScriptBlock() to inject the JS into the page, but that would overwrite any other function that might be in the master page, content page or other user controls.

Isn't there a way to just add an event to the page load on the client side and not worry about conflicting with other code?

Thanks,

John

Can you give an example of what you're trying to do?


I'm not sure I understand your problem, but if your user control inherits from Sys.UI.Control it's initialize method will be called when the page loads.

You can add your own pageLoad() handler by usingSys.Application.add_load().


HI,

I could use the page_load server event, but that would delay the rendering of the entire page until this process is complete. The effect I am looking for is to render a page so the user has something to look at. Then, when theclient on_load event fires, initiate some long running tasks that can take place while the user already has something to look at.

Thanks,

John


Sys.Application.Load is the client side event, not server side. Take a look at the documentation I linked. That's the event that pageLoad() calls implicitly.


Hi,

In the User control , write this function ,
<script>
function IAMIntheUserControl(object,eventArgs) {
}
</script>

register this script with RegisterClientScriptBlock.

Sys.Application.add_load( IAMIntheUserControl );

Monday, March 26, 2012

PageRequestManager : Whats the difference between doPostBack and _doCallBack ?

I want some parts of my web page refresh after a focus or changed event being made on a TextBox. What I want to acheive is get back to the server to do some code. I check the PageRequestManager and saw to way to make a postback to the server. What I want to do is get back to the server like I put a submit button without the whole page refresh. Some advices on that would be really appreciate !

It's not overly clear what your trying to do. Are you currently using UpdatePanels? If not, look into them:

http://www.asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx

http://www.asp.net/learn/ajax-videos/video-78.aspx

http://www.asp.net/learn/ajax-videos/video-159.aspx


I know it's not clear. I'm sorry. I'll try to explain more clearly.

On a client event like OnFocus or OnBlur or OnChange, I'll check some client state for the input (TextBox) and take decision if I need to get back to the server to refresh some part of my menu. I try to implement a sort of contextual menu. So, when some part (say inside panel1) got focus, I want to make an ajax request to add some stuff to the menu. When the panel lost focus, maybe I'll switch the visibiliy of some parts of the menu on the client side or got back to the server to do some job.

I'm building a sort of UIManager. This Manager need to check some client state(hidden field) and decide to get back to server if I doesn't have all the state it need to add some part of the menu for the contextual part.

So, I put the menu inside and UpdatePanel UpdateMode=Always. When a control (maybe TextBox, RadioButton or panel) got focus, maybe I need to get back to the server. I want to know if it's necessary to put the control inside and Update Panel or I can write some code to submit the form and use eventArgument to know what I have to do...

I hope is it a little be more clear. I appreciate a lot the time you take to help me !


Hi,

Thank you for your post!

Based on my understanding, you just want to refresh the updatepanel via javascript(e.g On a client event like OnFocus or OnBlur or OnChange).

Check out like this:

use __doPostBack to refresh the UpdatePanel

If you have further questions,let me know.

Best Regards,


Hi,

Thank you for this great anwser. It's really what I was searching.

I have another question. I need a way to pass parameter from the client to know what to do when the page refresh on the server. For example, when the TextChanged occured on the TextBox1, I want to update some parts of the menu. Is it a good approach to pass parameter on the EventArguments of the __doPostback ? And which format do you recommand I use ? Or can you recommand me another way of doing that ?

function TextChanged(){ __doPostBack('ClientAjaxComm','');}
Thanks!

Hi,

It is a good approach to pass parameter on the EventArguments of the __doPostback.

Or you can store something into something hiddenfield,and get them at the server side.

It is up to you to which approach you use.

Thanks!

pagerequest manager events seems to be raised to many times by the browser

Hello,

I have the next issue in my web application.

On server i'm sending to the client during a server event with registerdataitem a string -an url.

On client in pageloading i'm getting the url and showing into a popup window. This is the code:

var

wind=null;

var

currenturl=null;

var

i=0;

Sys.Application.add_load(ApplicationLoadHandler);

function

ApplicationLoadHandler(sender, args)

{

//Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(pageLoadingHandler)

}

//function EndRequestHandler(sender, args)

function

pageLoadingHandler(sender, args)

{

var dataItems = args.get_dataItems();

wind=document.getElementById(

'popupid');if (wind!=null)return;if (document.title.indexOf("Print")>=0)

currenturl=dataItems[

'ctl00_currenturl'];else

currenturl=dataItems[

'currenturl']if (currenturl !=null )//show the popup

{

wind=window.open(currenturl,

'popupid');

//DeleteFile(dataItems['currenturl']);works fine only on ie this solution

}

}

The problem is that the ajax pagerequestmanager event is raised too many times making the popup to be created to many time and sometimes browser to run out of resources.

How could i fix it i mean the pagerequestmanager event to be raised normaly i mean once.

I 'm using ie 6.5

Thanks

Hi,

Please use try this code snippet:

Sys.Application.add_load(ApplicationLoadHandler)

function ApplicationLoadHandler(sender, args)
{
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (!prm.get_isInAsyncPostBack())
{
prm.add_pageLoading(pageLoadingHandler);
}
}

Hope this helps.

PageRequestManager events being called too many times

I'm studying the PageRequestManager event lifecyle. It appears that when the number of times i click the linkbutton to perform the asynch postback, that same number of times the event is being called. Here's the scenario: I click the linkbutton once. Alerts for all events are called. I click the linkbutton once again. Alerts for all events are called twice. I click the linkbutton once again. Alerts for all events are called 3x. ... etc. Heres the sample code:

/*************************** aspx code ************************/

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="AsynchronousLifeCycle.js" />
</Scripts>
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Date: "></asp:Label><br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Push me!" />
</ContentTemplate>
</asp:UpdatePanel>
</form>

/******** js code *************************************/

Sys.Application.add_load(ApplicationLoadHandler)
Sys.Application.notifyScriptLoaded();


function ApplicationLoadHandler(sender, args)
{
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(InitializeRequest);
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequest);
Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(PageLoading);
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoaded);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
}

function InitializeRequest(sender, args)
{
alert("InitializeRequest");
}

function BeginRequest(sender, args)
{
alert("BeginRequest");
}

function PageLoading(sender, args)
{
alert("PageLoading");
}

function PageLoaded(sender, args)
{
alert("PageLoaded");
}

function PageLoaded(sender, args)
{
alert("PageLoaded");
}

function EndRequest(sender, args)
{
alert("EndRequest");
}

hi,

Please refer below URL:

http://ajax.asp.net/docs/ClientReference/Sys.WebForms/PageRequestManagerClass/PageRequestManagerBeginRequestEvent.aspx

Thanks

kishore

www.relgo.com.

PageRequestManager endRequest event not always firing

Hi,

I am using the ModalUpdateProgress control (http://www.codeproject.com/Ajax/ModalUpdateProgress.asp) and this hooks up an event handler to the PageRequestManager endRequest event but this is not always getting fired in Opera and Firefox. I can repro the problem in Opera but not FF (one user has reported this in FF).

I have posted a message to the forum for this control but thought that it might be a wider problem related to ASP.NET AJAX.

Any ideas?

Thanks,

Jason

Hi,Jason

Have you tested the PageRequestManager endRequest event without ModalUpdateProgress control?

If the PageRequestManager endRequest event always firing in other cases(I mean without PageRequestManager),The issue can be only a ModalUpdateProgress issue rather than an AJAX issue~

Thanks


Hi,

I tested hooking into the endRequest event manually (without the ModalUpdateProgress control) and it still doesn't get fired on this one page using Opera. It seems to work on all other pages though:

function pageLoad()
{
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);
}
function endRequest(sender, arg)
{
alert("here");
}

So, it does appear to be an issue with ajax rather than just the ModalUpdateProgress.

Any suggestions as to how I can debug this further?

Thanks,

Jason


OK...after discovering the error console in the Opera browser, I was able to determine that the problem is being caused by sliders within a modalpopup. These are generating a JS error that has a ripple on effect that breaks my pageLoad scripts, thereby preventing the endRequest from getting called. I have logged a bug report in codeplex for the sliders and will put protective code in my pageLoad scripts so that they don't error.

Saturday, March 24, 2012

Paint Event

I'm new to asp.net ajax. and Im using vb.net class to develop the page. Can the drawing class be implemented here? Is the picture box in vb same as image in asp? I tried with event handler for image1.paint but it .paint gives error...

No, images in ASp are completely different. You can use GDI+ to draw, however, but it's a bit different from winforms development. Consider the tutorial athttp://www.samspublishing.com/articles/article.asp?p=25487&seqNum=3&rl=1 as a decent place to start.

paul

Panel Default Button Event Doesnt Fire On Second Submit

I have one UpdatePanel surrounding a asp panel. Inside the panel I have one repeater, two buttons, and two labels. Inside the repeater's ItemTemplate I have an ImageButton and TextBox.

Here is the ASP Code:

1<asp:UpdatePanel ID="AdvancedSearchUpdatePanel" runat="server" UpdateMode="conditional" RenderMode="block" ChildrenAsTriggers="true">2 <ContentTemplate>3 <asp:Panel ID="AdvancedSearchPanel" runat="server" DefaultButton="SubmitSearchButton">4 <asp:Repeater ID="AdvancedSearchRepeater" runat="server">5 <HeaderTemplate>6 <table class="searchButton">7 <tr>8 <td colspan="100%">9 <asp:Label ID="KeywordLabel" runat="server" Text="Search By Keyword" Width="100%" Font-Bold="true"/>10 </td>11 </tr>12 </HeaderTemplate>13 <ItemTemplate>14 <tr>15 <td colspan="100%">16 <table cellpadding="0" cellspacing="0" style="padding-right:5px">17 <tr>18 <td>20 <asp:ImageButton ID="DeleteCriteriaButton" runat="server" ImageUrl="~/Resources/Images/close.gif" AlternateText="Click to Delete" OnClick="DeleteCriteriaButton_Click" />21 </td>22 <td>23 <asp:TextBox ID="KeywordTextBox" runat="server" Text='<%# Container.DataItem%>' CssClass="keywordSearch" Width="123px" OnTextChanged="KeywordTextBox_TextChanged" />24 </td>25 </tr>26 </table>27 </td>28 </tr>29 </ItemTemplate>30 <FooterTemplate>31 </table>32 </FooterTemplate>33 </asp:Repeater>34 <table class="searchButton">35 <tr>36 <td>37 <asp:Button ID="AddAnotherSearchButton" Text="Add Criteria" runat="server" OnClick="AddAnotherSearchButton_Click" />38 </td>39 <td>40 <asp:Button ID="SubmitSearchButton" Text="Submit Search" runat="server" OnClick="SubmitSearchButton_Click" />41 </td>42 </tr>43 <tr>44 <td colspan="100">45 <asp:Label ID="ReadableSqlString" runat="server" />46 </td>47 </tr>48 <tr>49 <td colspan="100">50 <asp:Label ID="ErrorLabel" runat="server" ForeColor="red"/>51 </td>52 </tr>53 </table>54 </asp:Panel>55 </ContentTemplate>56</asp:UpdatePanel>
My problem is that the default button for the panel is the SubmitSearchButton. 
On the first press of the enter key everything works as it should. 
On the second press of the enter key the DeleteCriteriaButton's (ImageButton) event gets fired because it is the first button in the panel. 
The only way I have seen to get around this is to put a button before the ImageButton that has a width of zero and have its event call the SubmitSearchButton event and everything works as should. 
Does anyone know a cleaner way around this problem or a reason this is happening. 
 
Thanks in advance.
There is a free component that allows you to assign a button to the "enter-pressed" client side event of input controls. If you type some text in textbox and press Enter, the form will postback, and the serverside click event of your button is fired.You don't need to write any code You only need to use control's "DefaultButton" property. It you are a beginner programmer this could be a life saver. More about MetaBuilders DefaultButtons Control you can find athttp://www.metabuilders.com/Tools/DefaultButtons.aspx
Wish this can help you.
You can specify a default button through javascript when pressing enter key.Try to take a look at this reading for details -http://www.beansoftware.com/ASP.NET-Tutorials/Accept-Enter-Key.aspx
Here are some sample codes for your reference.
TextBox1.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('"+Button1.UniqueID+"').click();return false;}} else {return true}; ");
Wish the above can help you.

DefaultButton is working fine for me on a simpler example:

<%@. Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" %><!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 click(object sender, EventArgs e) { label1.Text = string.Format("{0} pressed at {1}", ((Control)sender).ID, DateTime.Now.ToString()); }</script><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="up1" runat="server"> <ContentTemplate> <asp:Panel ID="panel1" runat="server" DefaultButton="button2"> <asp:TextBox ID="text1" runat="server" /> <asp:Button ID="button1" runat="server" OnClick="click" Text="one" /> <asp:Button ID="button2" runat="server" OnClick="click" Text="two" /> </asp:Panel> <asp:Label ID="label1" runat="server" /> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

This does what you'd expect... every time you type something and press enter, the label displays "button2 pressed at " followed by the current time.

Your sample is considerably more complicated (and hard to reproduce, since I would need to provide a datasource etc.). Could you try simplifying your code to see at what point the issue goes away?


You can't forget that in my code I have repeaters. This might be the problem. My quick fix is to put a button before the delete button and set it to call the submit button's click event. I know this is a hack and I'm working on other issues. Your help is greatly appreciated. FYI, the datasource of the repeater is a List<string>.
I tested your code with a asp:Panel(asp:Repeater) in a asp:UpdatePanel in my PC.My test enviroment isWindows Server 2003 Enterprise,VS.NET 2005 and Ajax RC1.0. I found it?could?work?fine.If?you?click?the?TextBox?and?press?Enter?key in theasp:Panel, the?default?button?of?the?asp:Panel will?be?triggered.If?the?current?focus?was?moved to?the?outside?of?the?asp:Panel?and?press?Enter?key, the?default?button?of?the?asp:Panel?can't?be?triggered.So if you want to pressEnter key in anywhere of the current web form and the default button of theasp:Panel will be triggered, try to focus on aTextBox of theasp:Panel throughjavascript when pressingEnter key in the web form.This should work fine for you.
Sample Code: document.forms[0].elements['txtBox'].focus();
Wish this can help you.
This works in Internet Explorer 7, but not in Fire Fox 2. I'm soooo surprised.

Wednesday, March 21, 2012

Partial rendering requires a browser that supports W3C DOM Level 1.0.

We have open a new web page using atlas in some parts.

Yesterday, I have check event log of the live site www.rusgelin.net

I saw hundreds of errors.

THe exception is "Partial rendering requires a browser that supports W3C DOM Level 1.0. ".

I might create my own browser detection logic in the atlas so if browser does not support atlas, I can easly disable script manager and replace new controls with old controls.

but this solution is not feasible solution. Please explain why does the error occur?

Sahin

I saw the same error, though I use Ajax beta 1.0. if this can't be sloved, I guess i have to turn off the Ajax beta, coz all the search engine spider can't index my web site.
hello.

well, that happens because?currently?the?client?side?features?need?a?browser?with?those?caracteristics?to?correctly?render?the?pages.?getting?those?warnings?means?that?you had several?browsers?not?compatible?with?dom?level?1?loading?the?pages.
all the error message are generated by spiders from like google , yahoo... why i concern this is if those spider can not access my site correctly, then my web site can not be indexed by those search engines, that will be a big problem.

.Net 2.0 is actually fairly good at detecting browsers / bots - so you can place some logic in your base page code that checks for the bot and disables the partialrendering...following is a simple code snippett -

If (HttpContext.Current.Request.Browser.Crawler == true)

{

<control logic to over-ride displaying of content (either allow or disallow)

}

else

{

(do the normal thing)

}


oh and if you haven't read this - it gives alot more detail...on the scm / enabling detecting etc...

Sorry, but that does nothing to address this problem -- the error is coming from UpdatePanel.

-MT


With Beta2 you can if the browser supports partial rendering declaring this in the page that contains the ScriptManager:


Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
If ScriptManager1.SupportsPartialRendering = True Then
ScriptManager1.EnablePartialRendering = True
Else
ScriptManager1.EnablePartialRendering = False
End If
End Sub

Cheers,
Juan


Will this cut out this error??

-- My system is throwing 100's these errors a day -- and I haven't even launched teh site!


Will this cut out this error??

-- My system is throwing 100's these errors a day -- and I haven't even launched the site!


Yes, it will... just try it...

After adding that piece of code to the PageInit Method, use whatever error tracking tool you are using to check that it's not throwing errors anymore


Hi,

Why dont you try with Beta2 , this is a new release of ASP.NET AJAX,

and you can also get the informatin about how to convert ATLAS to Beta2 inhttp://ajax.asp.net/default.aspx

Pradeep Kumar Bura


I was using up to now the Beta1 and encountering the raised exception for all search engine. Does the default settings of the Beta2 solve this problem directly, or do we need some extra settings to change or tweak?

Thanks in advance,
Joannès


I have the same question as Joannes and want to bring this thread back to the top of the list so someone might answer from MSFT.

Will/is theEnablePartialRendering property smart enough to set itself to false if the client browser does not support partial rendering?
Or will we have to performscriptManager1.EnablePartialRendering = scriptManager1.SupportsPartialRendering; on every page that uses a script manager?


hello.

well, currently, you have to do that :(