Showing posts with label partial. Show all posts
Showing posts with label partial. Show all posts

Wednesday, March 28, 2012

wierd behavior on submit button (partial postback acting as full postback randomly)

I setup this example from here, but I am getting some weird behaviour.

First off I was getting the pretty famous popup error of "unknown error" I was able to fix this by adding

<xhtmlConformancemode="Transitional"/>

to the web.config.

Right now the weird error that I am experiencing however is when I do a partial postback, the button actually does a full postback the first time, then after that it turns to partial post backs. This behaviour isn't always consistent, sometimes it takes 10 postbacks before it starts working as a proper AJAX partial postback.

Doesn't make any sense to me ?

Any one got an idea on this one? I copied the source directly from here, its very straightforward.

article

I have the same behavior. But I think in my case it is because I'm running vista RC1

If I clear my temporary internet files it seems to work ok for a while tho


I'm still running windows 2000 and its messing up, so I don't think it has anything to do with that.


At first clearing temp files seemed to help, but now it doesn't. It's so erratic that I can't come up with any possible ideas right now.

Anyone else experiencing this?

Thanks,

mike123

Monday, March 26, 2012

Win CE Support

Hi,

I'm developing a site for Win CE, which uses a version of IE6. I'm wanting to do partial page updates, but this functionality does not appear to be working. I'm using MS Ajax RC 1.0. I'm using a update panel coupled with a timer control which updates a grid at a regular time interval. This works fine on my development machine and other systems on IE6 & IE7, but in Win CE i get a full page update. There are no errors, but the partial update functionality is not working as it should. Any insight?

Thanks,

Josh

PocketPC and Smartphone devices 2003 and later, support AJAX. Read more about it here - http://blogs.msdn.com/iemobile/archive/2005/11/15/493200.aspx

Hi - thanks for the information. Looks intriguing. I take it that the MS AJAX controls are not supported?

Thanks again,

Josh

With AJAX, Using method="GET" instead of the default "POST" - possible?

Guys,

We are trying to use GET instead of POST to reduce the size of the packets sent to the server with each partial postback.

1) How do I do this? I tried specifying method="get" inside the form declaration, didn't work.

2) is this a stupid idea? Our viewstate can go to 8 kb or so. Does GET always tack on the view state to the

URL string?

Thanks !

http://kochukeralam.com

hello.

well, if i recall correctly, the only way you have to do that is to handle the client initializeRequest or beginrequest client event. for instance, if you choose to handle the beginrequest event, the method will receive a referece to the current webrequest object that is being used to make the call (again, we're talking about client objects, which means writing js). that object has a property called httpVerb which you can set to specify the type of call you're making

and yes, i'd probably stick with the post method...


The way a partial postback works, you NEED the ViewState in order to create an instance of the Page, run through its life cycle, and generate the HTML that needs to be returned to the PageRequestManager. So, even if you retooled it to use GET, you'd need to send the ViewState on the QueryString anyway (which would be difficult in the ~2k max you have to work with there).

You're right to be conscious of the ViewState size though. A better solution would be to look into changing where the ViewState is persisted at. Check this out: http://weblogs.asp.net/scottgu/archive/2006/06/18/PageStatePersister-Extensibility-with-ASP.NET-2.0.aspx


hello. hum, i'm not sure if i'm following. if I'm not mistaken, you can disable viewstate and the page should keep working without any problems...

Sure, if the page is designed to not rely on the ViewState (which is always a good option), then it's not needed for any type of request.

However, I believe the original poster was thinking if he could simply switch to a GET, then he could avoid sending the ViewState back to the server for partial postbacks. That wouldn't work, unless ViewState was persisted on the server side somehow (which would make GET and POST equally performant anyway).


hello again.

oh,. i see...then you're absolutely right.

Wednesday, March 21, 2012

Writing Javascript at Runtime on Update

Ok, I can't seem to find a shred of working advice on this topic. But, here are the basics.

Button inside of an updatepanel. Partial rendering is turned on.

Button gets clicked. Ajax call is made to the server. How do I at this point write javascript to the client's box that will execute, such as an alert.

Can't use Response.Write. Can't use ClientScript.Register... since that requires a full postback, unless I'm missing something. So...I'm not really sure what my other options are, surely someone else has run across this already. If you have any insight please share it with me.

Use EVAL() function of Javascript. It can be used as following,

<SCRIPT language="Javascript">

function Popup()

{

ExecJavascript("alert('Hi All');");

}

function ExecJavascript(var jscript);

{

eval(jscript);

}

</SCRIPT>


Use ScriptManager.RegisterStartupScript. Here's a working 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"> private void button_click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(up1, up1.GetType(), "myscript", "alert('Alert sent from server!')", true); }</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" UpdateMode="Conditional"> <ContentTemplate> <asp:Button ID="button1" runat="server" Text="Click Me" OnClick="button_click" /> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

hello.

or, if you don't need to return anything from the server, you can also hande the endrequest event of the client pagerequestmanager object which is available in all the pages that have updatepanels.

<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest( endRequest );

function endRequest( sender, e ) {
//put your code here.
}
</script


Perhaps I was not clear.

madesh, Your code is only from javascript to javascript. That isn't the issue.

Steve Marx, You don't have partial rendering enabled. You will find that enabling that will prevent your button from registering that script block because doing that requires a full post back.

Luis Abreu, I do need to send info back from the server.

Let me restate the problem. You're on the server, there isn't any javascript already on the client. You need to write some JS to the client, from a partial postback. ie, they just pressed the button, but it was through AJAX which means no script registering through the ClientScript object. So, during this partial post back, what are my options for sending a script block to the client?


Crap miss-read that Steve, I haven't tried it with the script manager, ill give that a shot when i get home. Why can't we edit posts?...


Excellent. Thanks Steve it worked. The trick is, you can't use Page as the control to register the script with. You have to use an existing control on the page, any will do. Even the update panel (up1). Thanks.

ZeroDegrez:

madesh, Your code is only from javascript to javascript. That isn't the issue.

Let me restate the problem. You're on the server, there isn't any javascript already on the client. You need to write some JS to the client, from a partial postback. ie, they just pressed the button, but it was through AJAX which means no script registering through the ClientScript object. So, during this partial post back, what are my options for sending a script block to the client?

As you stated that it is a AJAX call and Javascript gets generated on server side. EVAL can help you. Return your server generated Javascript to Client side as a string(Output of your AJAX call). Execute that Javascript on Client side using EVAL function.

This way you can execute the javascript returned by your AJAX call on client side.

<SCRIPT language="Javascript">

function AJAXcall()

{

var JScript={Put your AJAX call here};

ExecJScript(JScript);

}

function ExecJScript(var JScript)

{

eval(JScript);

}

</SCRIPT>