sharepoint how to add code handler for button click - sharepoint-2007

I have a SharePoint publishing page. I added a server button via SPD, assign the OnClick handler to btnSubscribe_Click. The question is, how and where can I add codes for this handler? If I have it inside a dll, how can I relate the SharePoint page to the .cs file?

You cannot add controls to publishing pages with SPD, I assume you mean you have added the button to the page layout? or master page?
To make an onclick work, as you know, you need to have a code behind, or script in code.
1) To make the code behind work, you need to make a custom page layout class, extend from Microsoft.SharePoint.Publishing.PublishingLayoutPage
Then change your page layout declaration to use your new page layout code:
<%# Page language="C#" Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
2) Or you can enable inline script through web.config, and have standard <script runat=server> sections
3) Or better yet, write a web part or a control that will do your subscribe action. And add that to your page layout.

Related

Can we check if page already has a form and avoid inner forms in jsf 2.2

We create command links on a page. The same command link is sometimes used on a different page of the web site. When first created because Page A does not have a form.
Scenario 1
Page A (no form on page)
Some text
Need a link. So, create command link surrounded by a form.
Scenario 2
Page B (reuse commandLink from Page A on page B)
<h:form>
Some text
Need a link. So, create command link surrounded by a form.
Reuse commandlink component from PageA
</h:form>
Throws an error, inner form exception.
Cannot use h:link because of url issues.
Can we use h:outputLink instead of commandLink to avoid form issues?
Can we create a custom jsf component to create commandLink. Check if form exists on page. If yes, do not add form. If no, add form around commandLink.
As a rule, do not put h:form tags in your JSF components. The h:form tag should wrap the component in the page you're using it, not in the component itself. That way you'll be able to mix them with other components in the same form providing you much more flexibility, at the little price of having two more lines of code. That's how is done in all the public component libraries, take a look to Primefaces as an example.
Apart from that, bear in mind that h:commandLink fires a POST request to the server, while you seem to be talking about plain links. In general, h:commandLink is used when you don't know the destination url at the time the view renders. I would suggest to avoid its use for any other case, because still you've got h:link for JSF destinations and h:outputLink for external destinations, you could even use a plain HTML anchor element. And, definitely, firing a GET request doesn't require a h:form tag.
See also:
"This link is deactivated, because it is not embedded in a JSF form."

jQuery Mobile pagechange event when replacing only content

I'm working on a jquery mobile project with a rails backend.
I have a "master" template, with the page structure as suggested from jQuery mobile website.
I have a multi-page system and for every page I have the same "master" template (header, footee...) and replace only the html in the <div data-role="content">.
So the header and footer are in the "master" template while the content changes for every page.
The problem is that I can't bind to any event because the page id is always the same, only the "content" div changes. This way if I subscribe to the "pagechange" event of the page, it fires for every page and I cannot apply a per-page javascript behaviour.
Do you have any suggestion on how to do this in a clean way?
Thank you,
Riccardo

User control in Umbraco

Hey frenz I am new to Umbraco cms. And I am building site using it.Here I need to include the
.net user control with some textboxs and submit button. But when I include the macro containing the .net user control in my templete and Run the site I got the error
Server Error in '/' Application.
Control 'ContentPlaceHolderDefault_News_2_Button1' of type 'Button' must be placed inside a form tag with runat=server.
I also watch the video tutorials about the Usercontrol in Umbraco. And followed the same process but i am still getting the error.
But it works fine if i used Html textbox and buttons
So, it there any solution for it.............
This is because the control 'ContentPlaceHolderDefault_News_2_Button1' of type 'Button' is not placed inside a form tag with runat=server.
Every ASP>NET control that have attribute runat="server" must be placed inside a form tag with runat=server.
The solution is easy:
Put the form into your user control
or
Make template that contains server form and acts as master page. Put your user control inside that template

ASP.net MVC 3 Ajax.beginform update and Client Side validation Problem

I am trying to update the partialview in which i used ajax.beginform. normally, first time it validate on client side but when i refresh the partial view innerHTML using outside button event, it is no more doing clientside validation on button submit.
It is working fine in google chrome but it is not working in IE 8, 9 or Mozilla.
Please find below link to download the sample project that i have created.
Download Sample
I found out a way to solve this situation.
Change 1
As on the sample project i referenced
two jquery scripts called Jquery.validate.min.js and jquery.validate.unobstusive.js on layout page but i didnt reference those jquery script file on my partial view.
Change 2
instead of updating the content of ajax.beginform in partialview, we need to update the container of ther partialview which is $("#dvPartialData").html(result) in Index view of home controller.

MOSS 2007: Changing the masterpage for one page layout

In a MOSS server, I would like a specific page layout to use the selected masterpage. Instead, i want this specific page layout to use a blank master page so i can use that page layout for pop message. I want to use a blank master page so that the my site's navigation menu, header and footer don't appear in my popup.
I found this blog post (Change MasterPageFile for a specific PageLayout) which explains how to do this but it requires the page to be ghosted which cannot be in my case.
Thanks
Create your own page layout in Sharepoint Designer, in the attributes of the page you can specify a masterpage url, instead of using the keywords ~default.master or ~custom.master use your own master page (make sure its published and available or it will fail).

Resources