0

i am using web farm solution and i have implemented few custom properties and my question is, is there a way i can enabled AJAX? when the user enter the bad name i validate in the prop and display error and its all working fine but it postback (repainting) the page.

private string _listName;
        [WebBrowsable(true), WebDisplayName("List Name"),   WebDescription("Enter ~ Separated List Name to Show Data Here.."),   Personalizable(PersonalizationScope.Shared),   System.ComponentModel.Category("Settings"),   System.ComponentModel.DefaultValue("")]
        public string ListName
        {
            get { return _listName; }
            set
            {
                if (string.IsNullOrEmpty(_listName))
                    throw new WebPartPageUserException("Please enter atleast one List Name here...");
                else
                    _listName = value;
            }
        }

1 Answer 1

1

Are you just wanting the webpart to repaint or some other part of the page?

If it's just your own webpart, then you can do one of two things.

  1. Add an update panel to your webpart and then put all of your controls in the update panel. This is probably the easiest but does have a lot of overhead and there is some complexity if you have multiple ones on the page.

  2. You could have your webpart implement ICallbackEventHandler. From here you can do an ajax call and that call will return a string. Then on the client side in JavaScript, you take that string that is returned and use it to update the html in your webpart using the dom. This solution is harder to impliment, but has less overhead.

2
  • have you done the option #1 and do you have sample code for that?
    – Nick Kahn
    Sep 2, 2011 at 18:09
  • I have, unfortunately the code is too much to post here. A quick google search revealed a blog which shows you how to implement an update panel in a SharePoint webpart: jamestsai.net/Blog/post/… Sep 2, 2011 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.