Ticket Q201214
Visible to All Users

How to clear a textbox from PageIndexChanged event

created 16 years ago

How can I raise a client side event after PageIndexChanged? Actually, the requirement is that I have some hidden fields whose value I need to clear after grids PageIndexChanged event is done on server side.

Show previous comments (2)
DevExpress Support Team 16 years ago

    Anurag,
    To determine that the callback is caused by changing the page index, use client-side properties enabled by the CustomJsProperties event.
    Attached is a sample project illustrating this approach in action. Hope this helps.
    BTW: Note that you can change hidden field values directly within the ASPxGridView.PageIndexChanged event handler.
    Thanks,
    Alex

    ?
    Unknown 16 years ago

      Hi Alex,
      Ideally I would like to change the hidden field value in pageindexchanged event but when I tried it didn't worked. the code is as given below. If I change these to ASPTextBox I can see the value is not set to blank.
      string selectedContactInfoIds = hidSelectedContactInfoIds.Value.Trim();
                  if (selectedContactInfoIds.EndsWith(","))
                  {
                      selectedContactInfoIds = selectedContactInfoIds.Substring(0, (selectedContactInfoIds.Length - 1));
                  }
                  string[] arrSelectedContactInfoIds = selectedContactInfoIds.Split(',');
                  for (int i = 0; i < arrSelectedContactInfoIds.Length; i++)
                  {
                      if (arrSelectedContactInfoIds[i] != string.Empty && !SelectedCustomerIds.Contains(Convert.ToInt32(arrSelectedContactInfoIds[i])))
                          SelectedCustomerIds.Add(Convert.ToInt32(arrSelectedContactInfoIds[i]));
                  }
      hidSelectedContactInfoIds.Value = string.Empty;
                  string unSelectedContactInfoIds = hidUnSelectedContactInfoIds.Value.Trim();
                  if (unSelectedContactInfoIds.EndsWith(","))
                  {
                      unSelectedContactInfoIds = unSelectedContactInfoIds.Substring(0, (unSelectedContactInfoIds.Length - 1));
                  }
                  string[] arrUnSelectedContactInfoIds = unSelectedContactInfoIds.Split(',');
                  for (int i = 0; i < arrUnSelectedContactInfoIds.Length; i++)
                  {
                      if (arrUnSelectedContactInfoIds[i] != string.Empty && SelectedCustomerIds.Contains(Convert.ToInt32(arrUnSelectedContactInfoIds[i])))
                          SelectedCustomerIds.Remove(Convert.ToInt32(arrUnSelectedContactInfoIds[i]));
                  }
      hidUnSelectedContactInfoIds.Value = string.Empty;

      DevExpress Support Team 16 years ago

        Hi Anurag,
        Thanks for the response. I'm afraid this behavior is by design.
        As mentioned in the Q142094 thread, it's not quite correct to modify other controls during the ASPxGridView callback.
        To modify hidden fields within the PageIndexChanged event handler, you might need to disable callbacks (see the ASPxGridView.EnableCallBacks property) and place both the text box and grid control onto the UpdatePanel. Let me know whether this makes sense.
        Thanks,
        Alex

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.