Showing posts with label panel. Show all posts
Showing posts with label panel. Show all posts

Monday, March 26, 2012

Instant Update Panel

I have a page on my site that displays one image, the user can post a comment about the image and rate it from 1-5 using the ajax rating control. The page entire page postbacks when the user posts a comment about the image. I am trying to get the comments gridview to postback on its own. The rating control and comment text box and gridview of comments is in a usercontrol. I put it on my photo.aspx page and then put it in an updatepanel. The user now can add a comment (and it does add) but the page still needs to be reloaded how to do you it to instantly update for new comments? Ive seen this on facebook if anyone is wondering where the influence for trying to do this is, can anyone recomend how to do this? thanks in advance ! si!

Throw your code here and let me see..


it took about an hour but it makes sense now! after the comment has been posted, I get it to reset the gridviews datasource and then databind it! haha, thanks thoughBig Smile si!

Saturday, March 24, 2012

Invalid postback or callback arguement?

Hey, i have a page with a gridview in an update panel, which has a triggered by the user clicking button1, the gridview has a row_command that deletes the data in the gridview, the code worked fine before i added the update panel, but now i tested my page again, i clicked button1, and then tryed to delete the new item in the gridview.

I got the error message "Event validation is enabled using <pages enableEventValidation="true"/> in the config or in the page head.

My page head bit reads :

<%@dotnet.itags.org. Page Language="C#" MasterPageFile="MasterPage.master" EnableEventValidation="true" AutoEventWireup="true" Inherits="Masters_Default2" Title="Untitled Page" %>

But i still get the error,... where am i going wrong? thanks Si!

Have a look at this blog:http://blogs.msdn.com/amitsh/archive/2007/07/31/why-i-get-invalid-postback-or-callback-argument-errors.aspx

-Damien


Make it false and then try...

Let me know what happend

Invalid postback or callback argument on page back

Hello,

I ran into this by placing myselft as the final user of my web application.

I have several pages using AJAX controls (update panel, autocomplete extender, etc), and I noticed that when I have redirect to another page, and till there, using the IE back page button, the previous page is loaded and then a message error is prompt (Invalid postback or callback argument)

By now I'm disabling the - PageEventValidation - but, actually I'd like to solve it in a better way.

Thanks in advance guys,

Hi Manotas,

Do you have databound controls, like a DropDownList or a GridView? If so, did you make sure they are initialized in a block that checks for inital page load?

For example:

if (false == Page.IsPostBack)

{

// code for initial load goes here

}

else

{

// code for PostBack from same page goes here

}

Pete


Hi Peter,

Thanks for reply.
I do have bound control. After reading at your post, I checked the initialization of my databound controls.
I realized that there is a gridview which I am initializing at first loading but not during postbacks, however, when the page is reload by using the back button on the browser, there is a postback and maybe is there where is my error. The thing is that I'm not sure what kind of validation I could do there since I wouldn't like to change the data of the parameters used on the select's datasource ...

I tried to find a pattern on the error... I must correct what I said about the invalid postback after the page's loading. In fact, I realized that it was happening only sometimes, and only when I was clicking on certain linkbuttons, on the other side, if I click on others buttons I was not having any problem at all. Also, as you mentioned the fact of look at databoud controls, I began testing and I found that I was getting the error only when I was turning back to the page and my gridview was visible (I'm using a multiview control, and the gridview I mentioned above is contained in its view).

By now, I restored the PageEventValidation and added at the update panel a postback trigger for the controls which are making visible my gridview.

Since I'm not receving the error message anymore... let's see I'l heard about it later...

Cheers

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

Invoke JavaScript method after partial post back

  Hi,
 Im trying to invoke a javascript method after a partial update has occured from an update panel. I found some code for which i beleive works for an old version, but it doesn't work for the released version.
 Does anyone know how i can invoke a javascript method after post back?
 
 
1 function afterPostback()2 {10 }1112 function PageRequestManagerPropertyChanged(sender, args)13 {14if (args.get_propertyName() =="inPostBack")15 {16if (!$object("_PageRequestManager").get_inPostBack())17 afterPostback();18 }19 }2021 function pageLoad()22 {23 $object("_PageRequestManager").propertyChanged.add(PageRequestManagerPropertyChanged);24 }

You can handle _endRequest to do that. Try something like this:

var prm = Sys.WebForms.PageRequestManager.getInstance();prm.add_endRequest(afterPostback);function afterPostback(sender, args){}

Note: This code has to be placed below the ScriptManager control.


Brilliant, that works a treat.

Thanks

Invoking postback for an update panel in a parent document

The default page for my website contains a div with links to user data that is only visible when a user is logged into my site. The login control lives in an IFrame within the default page (see sample code below).

Now, how can I get the udpate panel on the default page to recognize an event or a button click inside of the login control? I'm not looking for a tutorial on getting the login control to work, but rather any link button inside of the IFrame's update panel forcing the default page's update panel to post back. Both pages have a script manager.

chopped down version of existing code:

dafault page:

1<asp:update panel id="upUserPrefs" runat="server" updatemode="conditional">2 <contenttemplate>3 <div id="userPrefs" runat="server"><a href="prefs.aspx">preferences</a></div>4 </contenttemplate>5</asp:update panel>

IFrame source page:

1 <asp:UpdatePanel ID="updateSignon" runat="server" UpdateMode="conditional">2 <ContentTemplate>3 <asp:Table ID="tblLoginCtrl" runat="server" visible="false" Width="100%" HorizontalAlign="Left" CellPadding="0" CellSpacing="0">4 <asp:TableRow>5 <asp:TableCell ID="tcLoginCtrl">6 <uc1:LoginControl ID="LoginControl" Enable runat=server LoginStyle=Login_Home />7 </asp:TableCell>8 </asp:TableRow>9 </asp:Table>10 </ContentTemplate>11 </asp:UpdatePanel>
Any help would be greatly appreciated.

</p><p> (this.Parent.Parent as UpdatePanel).Update();</p><p>

is what I use.....however i have other problems...LOL. but that should fix yours.


Hi,

I think you can add a invisible button in the default page, set it as a trigger for the update panel.

Then add a javascript function in the contained page, in which invoke the click event of the button in the container.

Please feel free to let me know if there is any problem.


I tried that before, but when I have 2 instances of the same control on my page, it fires events for both of them. Or did I do something wrong?? Should this be happening? Have you ever heard of this??


In my opinion, it's normal that two control of the same type would behavior the same.

Wednesday, March 21, 2012

Is autopostback=true required on checkboxes for asyncpostbacks

My checkbox will only do postbacks when autopostback=true even when i have defined anAsyncPostBackTrigger trigger for the update panel. Is this behavior by design (see code below) ?

Thanks,

Brent

------

<%

@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajax" %>

<htmlxmlns="http://www.w3.org/1999/xhtml">

<body>

<formid="form1"runat="server"><div><asp:ScriptManagerID="ScriptManager1"runat="server"/><br/><asp:UpdatePanelID="UpdatePanel1"runat="server"ChildrenAsTriggers="False"UpdateMode="Conditional"><ContentTemplate><asp:LabelID="Label1"runat="server"Text="Label"Width="94px"></asp:Label><br/><asp:checkboxID="chk"runat="server"Text="Button"OnCheckedChanged="chk_CheckedChanged"/><br/><asp:ButtonID="Button1"runat="server"OnClick="Button1_Click"Text="Button"/><br/></ContentTemplate><Triggers><asp:AsyncPostBackTriggerControlID="chk"EventName="CheckedChanged"/></Triggers></asp:UpdatePanel><br/><asp:LabelID="Label2"runat="server"Text="Label"Width="91px"></asp:Label></div></form>

</

body>

</

html>

Public

PartialClass ajaxInherits System.Web.UI.PageProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load

Label1.Text = Now.ToLongTimeString

Label2.Text = Now.ToLongTimeString

EndSubProtectedSub Button1_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)

Label1.Text = Now.ToLongTimeString

UpdatePanel1.Update()

EndSubProtectedSub chk_CheckedChanged(ByVal senderAs System.Object,ByVal eAs System.EventArgs)'Never fires when checkbox is clicked unless autopostback=true.

Label1.Text = Now.ToLongTimeString

UpdatePanel1.Update()

EndSub

End

Class

yes, this is the correct behavior...
what it does is send a request to the server as soon as the checkbox status is changed.

So you're doing good :)

Great. Thanks for the confirmation, Peter.

Brent