Problem with Autopostback

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Problem with Autopostback

    I have a relatively long page with a number of webcontrols with
    "autopostback" set to true. The contents/items/datasources of the subsequent
    webcontrols are dynamically populated depending on the selection of previous
    webcontrols' selected item.

    My question is : everytime the user selects an option from a webcontrol, due
    to the autopostback being turned on, the page refreshes itself to populate
    the subsequent controls. The problem I have is that when it refreshes, it
    always ends up showing the top of my very long page.

    Are there anyway i could somehow return to the location of the last selected
    control that triggered that event or the next control after that? Anchors
    does not work here, does it? If not, then how do i do it?

    Please help!


    Jesse Guest

  2. Similar Questions and Discussions

    1. TabIndex and AutoPostBack
      I have a long form that includes several fields which require AutoPostBack=True. I want the user to be able to tab through the fields in sequence...
    2. no AutoPostBack for Grid?
      I have a grid with a select button. I went to turn off AutoPostBack and there is no such attribute. Is there any way to make a grid behave as...
    3. AutoPostBack
      I have another question. On my page there is a datagrid and in a templatecolumn it contains a dropdownlist. The AutoPostBack property of the...
    4. AutoPostBack question.
      Hi, I'm having a straight HTML <input type="text" onkeypress="CheckKey();"> within a <form runat="server">. When I press ENTER when in the...
    5. Can NOt AutoPostBack for two DDL
      Can NOt AutoPostBack for two DDL Posted: 07-03-2003 01:35 AM I have a usercontrol a.ascx ,put two DDL on the ascx. in an aspx's codebehind...
  3. #2

    Default Re: Problem with Autopostback

    Hi,

    Turn the smartnavigation on.

    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h[/url]
    tml/frlrfsystemwebuipageclasssmartnavigationtopic.asp

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  4. #3

    Default Re: Problem with Autopostback

    Add the following to the page directives, it works for ie5 and above maybe
    others
    <%@Page ... SmartNavigation="true"%>

    "Jesse" <jesselch@hotmail.com> wrote in message
    news:eUeqcPBTDHA.2852@tk2msftngp13.phx.gbl...
    > I have a relatively long page with a number of webcontrols with
    > "autopostback" set to true. The contents/items/datasources of the
    subsequent
    > webcontrols are dynamically populated depending on the selection of
    previous
    > webcontrols' selected item.
    >
    > My question is : everytime the user selects an option from a webcontrol,
    due
    > to the autopostback being turned on, the page refreshes itself to populate
    > the subsequent controls. The problem I have is that when it refreshes, it
    > always ends up showing the top of my very long page.
    >
    > Are there anyway i could somehow return to the location of the last
    selected
    > control that triggered that event or the next control after that? Anchors
    > does not work here, does it? If not, then how do i do it?
    >
    > Please help!
    >
    >

    Jason Turim Guest

  5. #4

    Default Re: Problem with Autopostback

    "Jesse" <jesselch@hotmail.com> wrote in message
    news:eUeqcPBTDHA.2852@tk2msftngp13.phx.gbl...
    > I have a relatively long page with a number of webcontrols with
    > "autopostback" set to true. The contents/items/datasources of the
    subsequent
    > webcontrols are dynamically populated depending on the selection of
    previous
    > webcontrols' selected item.
    >
    > My question is : everytime the user selects an option from a webcontrol,
    due
    > to the autopostback being turned on, the page refreshes itself to populate
    > the subsequent controls. The problem I have is that when it refreshes, it
    > always ends up showing the top of my very long page.
    >
    > Are there anyway i could somehow return to the location of the last
    selected
    > control that triggered that event or the next control after that? Anchors
    > does not work here, does it? If not, then how do i do it?
    To make a workaround in other browsers apart from IE5 and 6, you could
    think of inserting a numbered bookmark with each control:
    <a name="bookmark01">&nbsp</a>

    Then, on postback, insert a script to go to the right bookmark:
    Sub InsertScriptBlock()
    Dim jScript As new System.Text.StringBuilder()
    jScript.Append("<script language='JavaScript'>")
    jScript.Append("location.href='#bookmark01';")
    jScript.Append("</scr" & "ipt>")
    Me.RegisterClientScriptBlock("Bookmark", jScript.ToString())
    End Sub

    --

    Jos Branders


    Jos Branders Guest

  6. #5

    Default Re: Problem with Autopostback

    Thank you Natty Gur!
    Thank you Jason Turim!
    Thank you Jos Branders!

    You guys just saved my life!!!

    "Jesse" <jesselch@hotmail.com> wrote in message
    news:eUeqcPBTDHA.2852@tk2msftngp13.phx.gbl...
    > I have a relatively long page with a number of webcontrols with
    > "autopostback" set to true. The contents/items/datasources of the
    subsequent
    > webcontrols are dynamically populated depending on the selection of
    previous
    > webcontrols' selected item.
    >
    > My question is : everytime the user selects an option from a webcontrol,
    due
    > to the autopostback being turned on, the page refreshes itself to populate
    > the subsequent controls. The problem I have is that when it refreshes, it
    > always ends up showing the top of my very long page.
    >
    > Are there anyway i could somehow return to the location of the last
    selected
    > control that triggered that event or the next control after that? Anchors
    > does not work here, does it? If not, then how do i do it?
    >
    > Please help!
    >
    >

    Jesse Guest

  7. #6

    Default Problem with Autopostback

    Hi,

    I have a set of Dynamic DropDownLists with AutoPostback. the problem I
    have is that when I select the dropdown and the page refreshes the old
    values in the text boxes disappear. Is there a way to preserve the
    values?

    Thanks,
    Mo
    mo Guest

  8. #7

    Default RE: Problem with Autopostback

    Make sure you are not accidentally re-initializing your controls. All
    controls have viewstate to maintain their values, and therefore in your
    Page_Load event you need to make sure you only initialize your drop-downs
    when the page is first being requested via HTTP GET request and not during an
    HTTP POST request.

    inside Page_Load:

    public void Page_Load(object sender, EventArgs e)
    {
    if (!Page.IsPostBack)
    {
    //Initialize drop downs here
    }
    }

    "mo" wrote:
    > Hi,
    >
    > I have a set of Dynamic DropDownLists with AutoPostback. the problem I
    > have is that when I select the dropdown and the page refreshes the old
    > values in the text boxes disappear. Is there a way to preserve the
    > values?
    >
    > Thanks,
    > Mo
    >
    Jorge Matos Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139