.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

unecessary postbacks

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
Hi I am trying to delete or add rows in a table but since the table is in an update panel, upon deletion the row goes away and then comes back. I have tried using return false but it does not seem to work in IE or FF. I am using the following code:$(document).ready(function () {$(.table).click (function ()}(this).parent().remove();});return false;});Basically I need a way to disable the postback.Thanks

View Complete Post

More Related Resource Links

postbacks and url rewriting


Hi all,

I am using Intelligencia url rewriter for my project and have run in a small problem. I have a regular expression like

<rewrite url="~/(.+)/(.+)/(.+).aspx" to="~/Article.aspx?a=$3&amp;s=$2&amp;p=$1"/>

so a page request like

/parent/category/articlename.aspx is interpreted as /Article.aspx?a=articlename&s=category&p=parent.

This above is all fine, but now when I do a postback (a login block), it picks up the url /Article.aspx?a=articlename&s=category&p=parent and interprets as /Article.aspx?a=article&s=category&p=parent.

Now, how can I make sure that on the postback, it still throws back the original url /parent/category/articlename.aspx so that the url is properly interpreted?


Keep "collapsed" state of CollapsiblePanelExtender between postbacks



I have created a UserControl with a CollapsiblePanelExtender inside. In my Web page, I have a PlaceHolder in which many UserControls are added dynamically at every PostBack.

Everytime my page reloads, the CollapsiblePanelExtenders are expanded, even if they were collapsed before the PostBack. Is there a way to keep track of the "collapsed" state of the CollapsiblePanelExtender ? It seems hard since there is no server event triggered when the panel is collapsed / expanded.

Someone seemed to have the same problem here : http://forums.asp.net/p/1094970/1650425.aspx. I tried his solution (accessing the ClientState of the CollapsiblePanelExtenders using Request.Form) but my values are always null or true, even if the CollapsiblePanel is collapsed before PostBack.

Here is some piece of code :

AUMBlock block = (AUMBlock)Page.LoadControl("AUMBlock.ascx");
//CollapsiblePanelExtender cpe = (CollapsiblePanelExtender)block.FindControl("cpe");
//string clientState = cpe.ClientState;

General Question About Remembering Property Values Between Postbacks

Here are examples of two different ways I've found to story Property values between postbacks:    private bool Initialized    {      get      {        return Convert.ToBoolean(this.Attributes["Initialized"]);      }      set      {        this.Attributes["Initialized"] = value.ToString();      }    }    private int DataTableRowIndex    {      get      {        return (int)ViewState["DataTableRowIndex"];      }      set      {        ViewState["DataTableRowIndex"] = value;      }    }I'd appreciate any comments about differences between these two approaches [Attributes vs. ViewState].  Is one better or worse?Robert

How to Pass a Grid an EF Object and have it edit/update etc. without postbacks until save?

Hey all.Here's what I'm trying to do:I want to pull an EF object, or create a new one. Pass it to javascript (jquery or some such) and then have the grid bind on the client side and do everything client side from that point forward. (edits, validation etc.) Once complete, I want jquery to push back via a pagemethod or web service or whatever, the updated EF object so that i can persist it.Reason?I need a highly scalable architecture that handles not storing objects in the session or posting to a database when they haven't been saved to a user. I know I can do this with Silverlight, however given MS's less than convincing comments about Silverlight's future vs HTML 5, I'm strongly leaning towards asp.net or mvc.net if I can come up with a way to use jquery (or even a 3rd party control that does this!) to handle all of the data editing, updating etc. for a master/child display (i.e. Invoice) without the server having to store it and without having to use the viewstate.Ideas?In my mind this would be the holly grail. Render the page, push the data to the controls, have the controls do their thing until save without ever doing server processing, and then on save, push back the object and allow the server to persist it (and probably do server validation before presisting it just in case). By doing this you could make superscalable apps that

UpdatePanel in .Net 4 - Causing Full Page Postbacks

Hi Guys,I've just updated a website from 3.5 to 4.0 and I've noticed that paging controls and command buttons in update panels cause full page postbacks (where they never use to in my 3.5 version).Any ideas why this might be?Cheers,Andrew

Play uninterrupted music across postbacks

Hi,I'm in need of providing uninterrupted music to the visitor of my web site.The music is played by a 3rd party Flash object. I need to some how maintain an instance of this flash object in memory so that the visitor of the site will experience uninterrupted music (even while navigating to the other pages in the site).The idea is to have one instance in memory (hidden which survives postbacks) and the othe displayed to the visitor (this will sync up with the hidden player).If you suggest using iFrame in a master page, pl let me know how to handle multiple master pages scenario. My site contains more than one master page. And with iFrame we don't get to see the actual URL being served in the address bar.I know pop-up window is another option. But would like to know if I can do anything with the iFrame.Thanks.

Partial view and postbacks - undesired results

Sorry for the long post,I'm having problems after the postback. Each time I post back the changes made on the ui - I see the changes in the RateViewModel passed back, but the code populates each control in the table with these values - instead of the values from the ViewModel. What am I doing wrong?Object.public class CurrentAndFutureRate{        public int ParentID { get; set; }        public int ParentTypeID { get; set; }        public string ParentTypeDescription { get; set; }        public decimal CurrentRateValue { get; set; }        public DateTime CurrentStartDate { get; set; }        public DateTime? CurrentEndDate { get; set; }}View Modelspublic class CurrentAndFutureRateViewModel { public List<CurrentAndFutureRate> CurrentAndFutureRates { get; set; } } public class RateViewModel { public int ParentID { get; set; } public int ParentTypeID { get; set; } public int? RateID { get; set; } public decimal RateValue { get; set; } public DateTime StartDate { get; set; } public DateTime? EndDate { get; set; } } Master page renders a partial view(1) and the partial view displays a table

Problems with postbacks, visible/hidden controls



I am having some unusual issues with web forms on my public-facing internet servers.  I can run everything fine both locally and on my internal intranet servers.  I have forms that show or hide table rows depending on what step you are on in the form.  This form reads and writes to a SQL database via a Web Service.  I have eliminated AJAX or JavaScript issues by creating a simple test form that is showing the same erronious behavior...

Web Service:

using System;
using System.IO;
using System.Web.Services;
using System.Xml;
using taExternalTestTableAdapters;

namespace nsExternalTest
    [WebService(Namespace = "nsExternalTest")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class ExternalTest : System.Web.Services.WebService

        public ExternalTest()

        public int GetEmpID(string empLogin)
            EmpTableTableAdapter taEmp = new EmpTableTableAdapter();
            return Convert.ToInt32(taEmp.GetEmpID(empLogin));
        public bool InsertMessage(string message, string empID)
            bool success = true;
                TestTableTableAdapter taTestTable = new TestTableTableAdapter();

Detecting postbacks in javascript only


  I have a javascript function that fires by clicking any element on the asp.net webpage.
When it fires, we have three scenarios:
1- full postback (when clicking on a button outside the update panel)
2- Partial postback (when clicking on a button inside the update panel)
3- No postback (when clicking on a table cell for instance)

I was able to detect when a partial postback occurs by using the async property demonstrated
below, but I could not find a way to differentiate between a full postback and a no
postback within the bodyclick event. The reason is that in both conditions the 'Asynchronous' variable
would be false. Any ideas?

function bodyClick() {
 var Asynchronous = false;
 Asynchronous = Sys.WebForms.PageRequestManager.getInstance()._postBackSettings.async;

<body onclick="bodyClick()">

Persisting DropDown List attributes accross page Postbacks


Can anyone advice how can DropDownList attributes be persisted accross page Postbacks?


DropdownList1.AutoPostBack = True

On Postback the attribute is no longer available (ie. attributes.count=0).
I tried persisting using the code below, but was unsuccessful:

Before PostBack: ViewState.Add("DDL","DropdownList1")
On PostBack: DropdownList1 = ViewState("DDL")

This generated the error: DropDownlist is not marked as serializable.

I than tried:

Before PostBack: Session.Add("DDL","DropdownList1")
On PostBack: DropdownList1 = Session("DDL")

This did not err but attributes were still not available.

Ideas Anyone?








Cookies and postbacks



I wonder if anyone can help me understand the following.

If I have a click event that updates Session, I know that I cannot access the updated session value until the prerender event because of the page lifecycle.  However this is not the same with cookies.

I changed a variable that was stored in Session to be stored in a cookie.  The same sequence of events occurred - click - get current value - update value - store new value.  In this case is was revaking a cookie.  If I then access the cookie again at prerender the cookie value hasn't changed.

Can anyone in the know please explain why this is?



Make several changes across postbacks to an object in EF data module and view changes before persist


Is there a way to make several changes across postbacks to an object in an Entity Framework (.net 4) data module, view the data with changes (such as in a gridview), and then user clicks save to persist to the database?

Persisting a DataTable between Postbacks


Hey, guys.

Just wondering what the most effective method is to persist the data of a DataTable between postbacks.


ImageButton postbacks even when not inside UpdatePanel.


I am having a custom ASPX page with following structure. Its having 2 update panel and I have a ImageButton outside them. The two UpdatPanel are triggered by this ImageButton.

The Problem is whenever user clicks the Imagebutton, the image in the ImageButton is getting reloaded...it disappears and the reappears. I am not able to figure out why the postback is happening when the imagebutton is place outside UpdatePanel. Is it because I am using this Imagebutton for triggering AsyncPostBack in UpdatePanel?
Any suggestion would be helpful....


        <asp:ImageButton id="myButton" onclick="myButton_Click" OnClientClick=".." runat="server" ImageUrl="..." />
        <asp:UpdatePanel ID="updG" runat="server" UpdateMode="Conditional">
                <cst:myGrid id="cstgrid">
                <asp:AsyncPostBackTrigger ControlID="myButton" />
        <asp:UpdatePanel ID="updS" runat="server" UpdateMode="Conditional">
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend