Showing posts with label figure. Show all posts
Showing posts with label figure. Show all posts

Saturday, March 24, 2012

Invalid viewstate

I'm having no fun trying to figure out why I keep getting an invalid viewstate when I do a page refresh for this code:
<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false" Title="Test"%><script runat="server"> Protected Sub Test_OnCommand(ByVal sender As Object, ByVal Args As CommandEventArgs) Test.Visible = False End Sub </script><form runat="server" id="hello"><asp:ScriptManager id="ScriptManager1" runat="server"></asp:ScriptManager> <asp:UpdatePanel id="UpdatePanel1" runat="server" updatemode="Conditional" visible="true"> <ContentTemplate> <asp:Button id="Test" text="Generate" runat="server" enableviewstate="true" width="100" oncommand="Test_OnCommand"></asp:Button> </ContentTemplate> </asp:UpdatePanel></form>
Your help would be greatly appreciated :-)

The code runs just fine on my PC.


The code works fine on my computer. Have you updated your version of Visual Studio with Service Pack 1. It was suppose to provide better support for Ajax. Maybe thats the problem, i can't be sure.

Invoke Javascript method after partial postback ?

Howdy All,

This might be an easy one but I don't seem to be able to figure it out.

Basically I have an update panel which contains a button that causes the partial postback. After the postback I'd like it to call a Javascript method.

I tried looking to set it on an atlas object and I even tried some hacks like putting a literal control in the Update Panel and setting the text to <script language=""Javascript"">testFunction();</script>" but still no cigar.

Any help would be greatly appreciated.

Try registering your script on the server-side, during the partial post. The script you register will be executed when the response is received from the partial postback.

Page.ClientScript.RegisterStartupScript

-Tony


in my callback function i havestring js = "alert('s');"; Page.ClientScript.RegisterStartupScript(GetType(), "key", js);It doesn't fire

casaubon:

in my callback function i have string js = "alert('s');"; Page.ClientScript.RegisterStartupScript(GetType(), "key", js); It doesn't fire

You need to wrap your js in <script type="text/javascript"> </script>, or use the overloaded RegisterStartupScript specifying "true" for the last parameter.

Hope this helps,

-Tony