How to add code to SharePoint 2010 master page - sharepoint-2010

I have created custom master page with custom elements included according to this link: http://msdn.microsoft.com/en-us/library/gg447066.aspx
I want to have a Suggestions form in header area where users can leave their comments/suggestions on what functionality they would like to have.
For example:
User goes to company team site and notes that it would be great to have a clock on it
User fills the Suggestions form and the suggestion is emailed to me
Now I decide will I implement/develop it or not
I have placed all html elements and now I need code implementation. My question is: "How to code html elements to achieve desired functionality?".
Tried to follow up through this solution to add code behind masterpage: http://rburgundy.wordpress.com/2010/03/10/sharepoint-2010-custom-masterpage-with-code-behind-file-%E2%80%93-part-2/
but I get an error which I don't know how to handle.
Here is the error:
Parser Error Description: An error occurred during the parsing of a
resource required to service this request. Please review the following
specific parse error details and modify your source file
appropriately. Parser Error Message: Could not load the assembly
'Branding102, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=84d1d0117dd4046d'. Make sure that it is compiled before
accessing the page.
Source Error: Line 1:
I need to implement _starter.cs file as code-behind masterpage.

Don't bother with webparts in your master page.
Delegate control is your friend.
http://msdn.microsoft.com/en-us/library/ff650763.aspx
http://fyeomans.com/2011/05/16/make-your-sharepoint-2010-master-page-extensible-with-delegate-controls/
You can write your delegate control to be full postback or Ajax, implementation is up to you.
Personally, having webparts in masterpage is a no-no for me, that's what page layouts are for. In masterpage, delegate control is THE prefered method to have custom html/code rendering.

http://edwin.vriethoff.net/2007/10/02/how-to-send-an-e-mail-with-attachment-from-sharepoint/
Something like this within a web part and then add a web part to your master page.
Hope this helps

Related

Sharepoint 2010 custom content type does not show in list creation screen

I have a content type that was created by another developer long ago. After deployment, the content type does not show up in the list creation screen. Even when filtering lists and custom types. It's just not there anywhere. The feature is successfully deployed and if I do a template of the list from another farm, and then create the list from that template everything works as expected.
Thanks for anyone that knows what I might be missing here.
The answer was that it needs to have a list definition added to the project.

How does jQuery's FileUpload's Backload connect with UploadHandler?

I got jQuery File Upload along with Backload up and running in Visual Studio, straight out of NuGet. The demo works just fine, I can upload files. I'm using the default configuration.
http://blueimp.github.io/jQuery-File-Upload/basic.html
https://github.com/blackcity/Backload
BackloadDemo/Index.cshtml has the following form:
<form id="fileupload"
action="/Backload/UploadHandler"
method="POST"
enctype="multipart/form-data">
It works, but I can't figure out how it works. Where does /Backload/UploadHandler link to? I cannot find any reference of this 'UploadHandler'.
I was trying to figure the same thing out and I have found the answer.
If you check the Backload.dll you will see a namespace of Backload.Controllers with a class named BackloadController.
This is the controller that is picking up and handling the request. ASP.Net uses reflection to gather all classes that end with Controller and inherit from Controller. The reason you can't see this controller in the Controllers folder is because they are embedding the implementation inside the Backload.dll
From your second link:
Backload is a professional, full featured file upload controller and handler (server side) for ASP.NET
So the request to /Backload/UploadHandler either gets intercepted by a handler or picked up by a controller.
If your actual question is "How do I incorporate Backload in my project", then refer to their documentation or show relevant code and explain what you did, what you expect to happen and what actually happens.

PrestaShop - Reload CMS page with additional parameters

Situation: I needed to add form with POST method to CMS page. I created custom hook and a module displaying the form successfully. Then I need to react to user input errors eg. when user doesn't enter email address I need to detect it, display the whole page again together with the form and with "errors" in user input clearly stated.
Problem: The problem is to display the WHOLE page again with connected information (eg. about errors etc.). In the module PHP file when I add this kind of code,
return $this->display(__FILE__, 'modulename.tpl');
it (naturally) displays ONLY the form, not the whole CMS page with the form.
In case of this code,
Tools::redirectLink('cms.php?id_cms=7');
I can't get to transfer any information by GET neither POST method.
$_POST['test'] = 1;
Tools::redirectLink('cms.php?id_cms=7&test');
I tried to assign to smarty variables too
$smarty->assign('test', '1');
(I need to use it in .tpl file where the form itself is created) but no way to get it work.
{if isset($test)}...,
{if isset($smarty.post.test)}...,
{if isset($_POST['test'])}... {* neither of these conditionals end up as true *}
Even assigning a GET parameter to url has no impact, because there is link rewriting to some kind of friendly url I guess, no matter I included other argument or not. ([SHOPNAME]/cms.php?id_cms=7&test -> [SHOPNAME]/content/7-cmspage-name)
My question is: is there a way to "redirect" or "reload" current page (or possibly any page generally) in prestashop together with my own data included?
I kind of explained the whole case so I'm open to hear a better overall solution than my (maybe I'm thinking about the case in a wrong way at all). This would be other possible answer.
The simplest method would be to use javascript to validate the form - you can use jQuery to highlight the fields that are in error; providing visual feedback on how the submission failed. In effect you don't allow the user to submit the form (and thus leave the page) until you're happy that the action will succeed. I assume that you will then redirect to another page once a successful submission has been received.
There's lots of articles and how-tos available for using javascript, and indeed jQuery for form validation. If you want to keep the site lean and mean, then you can provide an override for the CMS controller and only enqueue the script for the specific page(s) you want to use form validation on.
If the validation is complex, then you might be best using AJAX and just reloading the form section of your page via a call to your module. Hooks aren't great for this kind of thing, so you might want to consider using an alternative mnethod to inject your code onto the cms page. I've written a few articles on this alternative approach which can be found on my prestashop blog

Having codebehind for Custom .aspx page in sandbox solution

I am having working with sandbox solution. i have one .aspx page in my solution and i have placed one button tag in that page, i need to write server side code for that button. But it is showing "The event handler 'OnClick' is not allowed in this page." . Does codebehind is not allowed in sandbox solution. Or indirectly how can i write my c# code for that button.
I know we can do it by creating one webpart and show that webpart in page using "WebPartPages:SPUserCodeWebPart" tag . But i want to confirm whether we can write codebehind for an asp page in some way or not.
Without changing the web.config file (which would not be recommended in this case), inline code or code behind files are not supported outside of the layouts folder (which you cannot deploy to with a sandbox solution).
However, you should be able to create a class and then set the inherits attribute to point to that class, instead of referring to the class in a code behind file.

Wiki Page Library issue in SharePoint 2010

I would really appreciate it if someone would help me out with this issue.
I'm using SharePoint 2010. I created a Wiki Page Library without changing any of the library settings, and created a new Wiki page, all that went fine but once I started adding text and then tried to save the changes on the page, this message appears:
"You must specify a value for this required field"
I don't know what to do, there is no required field and I can't really fix that... so please help me with that message!!
Fatima, I don't know if you ever got your question answered, but this is a known issue with Publishing features. There is a field that is marked as required, but is not displayed on the page. I beleive it's the column/field called "Name". If you look through the Site Content Types and find "wiki page", you'll see that status is marked as "Required". Changing that should fix the issue for you.
This was caused by a Place holder missing from the Main area of your master page.
Even if you’ve moved it to a asp:Panel and declared it as false at the bottom of your master page you’ll still get the error.
All you need is to move content place holder
<asp:ContentPlaceHolder id=“PlaceHolderPageTitleInTitleArea” runat=”server”></asp:ContentPlaceHolder>
within the s4-bodyContainer div , within the s4-ca div seems to work best. Save the master page and that’s it. that no more irritating message.
Reference: http://sharepointbrandingteam.wordpress.com/2012/05/25/sharepoint-2010-error-you-must-specify-a-value-for-this-required-field/
Alternatively, you can try the solution suggested here