Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to create a Button in my Ribbon which modifies some fields in my items.. In details I want to select more than one element and select my "link" button and make the elements be "linked" by an integer field populated with the same value.

I already have other ribbon custom button but for those it was easy to work only with Javascript. Can anybody suggest me how to do this thing?

I read online someone suggest to create a custom WebControl invoked by "postback" to react to event... There is any other way or a good tutorial?

Thank you very much!

share|improve this question

4 Answers

up vote 2 down vote accepted

Use __doPostback method on the client:

__doPostback('myPostBack','');

Then, on server you should have something like this:

const string myPostBackId = "myPostBack";

public override CreateChildControls()
{
    // ...

    if (this.Page.Request["__EVENTTARGET"] == myPostbackId)
    {
        string textBoxValue = this.Page.Request["__EVENTARGUMENT"];
        // do whatever you need with textBoxValue
    }

    // ...
}

Also, I have two working examples for my Fluent Ribbon API opensource project, of how to work with postbacks. I think, exploring these examples could help, even if you don't intend to use Fluent Ribbon API. Here they are:

  1. Simple example from the project documentation site
  2. Article, which explains how to use Ribbon ToggleButton in conjunction with UpdatePanel to create multiview pages
share|improve this answer

You could also create an application page which you pass the GUIDs of the selected items via a JavaScript redirect. currentsite/_layouts/AppPage?GUIDS=guid1,guid2&ReturnURL=/Pages/currentpage.

Have your code complete the request then redirect to the list view via the ReturnUrl paramater.

share|improve this answer

Apart from invoking server side code from Ribbon using _dopostback, there are other ways of doing it as well as described here on my blog http://sharepointnadeem.blogspot.in/2012/07/invoke-server-side-code-on-sharepoint_9855.html

share|improve this answer
While this may theoretically answer the question, we prefer inclusion of the essential parts of the answer here, and to provide the link for reference. See answer for general guidelines. Also we require relevant answers and disclosure of any affiliation with products or websites. Please see May I promote products or websites I am affiliated with here? for guidelines. Please fix this and flag for a moderator to review. Thanks. – SPDoctor Jul 15 '12 at 8:37

Apart the suggestion wrote from Andrey and Anders I suggest to you another solution. By javascript call a wcf to do the work do you need.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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