I wanted to have a feedback form in the sharepoint site as a part of user requirement. The primary idea was to add a small hyperlink in the sharepoint site and make it open the default email client when user clicks on it.....sounds pretty easy!!!....but bad idea
i wanted to link in the welcome menu in sharepoint which would popup a page and user enters his feedback into the window. Once the feedback is submitted an email should be send to the user thanking him for the feedback and a notification should be send to the system administrator about the feedback.
The first challenge is to add a menu to the sharepoint welcome menu. This is to done using visual studio.
Step 1:
Create a new empty sharepoint project i called it userfeedback.
Step 2:
Add a new empty element named userfeedback
Step 3:
Add a new application page in the layout folder which will be displayed once the user clicks on the feedback menu. Also add a small icon in the layout folder which appears as icon in the menu. The details about the application page will be explained later.
Step 4:
Open the elements.xml file and replace the existing code with the following code.
-------------------------Start Script------------------------
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="CustomGlobalLinks" ImageUrl="/_layouts/UserFeedback/Feedback.jpg" Description="Provide feedback or Submit an Enhancement Request"
Location="Microsoft.SharePoint.StandardMenu" GroupId="PersonalActions" Sequence="1001" Title="Feedback">
<UrlAction Url="javascript:(function () { var o = { url:'/_layouts/UserFeedback/UserFeedback.aspx', title: 'Feedback', allowMaximize: false, showClose: true, width: 502, height: 295 }; SP.UI.ModalDialog.showModalDialog(o); }) ();"/>
</CustomAction>
</Elements>
-------------------------End Script------------------------
This piece of code adds a feedback menu in sharepoint welcome menu.The custom action id is telling the system where to add the menu. The image URL is the icon that is displayed in the menu. I am using a JavaScript to open a sharepoint modal popup window displaying the feedback form.
Step 5:
Open up the design of the application page. Add a dropdown control named feedbacktype and multiline textbox named feedback description. add two buttons for sumitting the feedback and other for cancel. The end result that i created looked like this...
The first challenge is to add a menu to the sharepoint welcome menu. This is to done using visual studio.
Step 1:
Create a new empty sharepoint project i called it userfeedback.
Step 2:
Add a new empty element named userfeedback
Step 3:
Add a new application page in the layout folder which will be displayed once the user clicks on the feedback menu. Also add a small icon in the layout folder which appears as icon in the menu. The details about the application page will be explained later.
Step 4:
Open the elements.xml file and replace the existing code with the following code.
-------------------------Start Script------------------------
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="CustomGlobalLinks" ImageUrl="/_layouts/UserFeedback/Feedback.jpg" Description="Provide feedback or Submit an Enhancement Request"
Location="Microsoft.SharePoint.StandardMenu" GroupId="PersonalActions" Sequence="1001" Title="Feedback">
<UrlAction Url="javascript:(function () { var o = { url:'/_layouts/UserFeedback/UserFeedback.aspx', title: 'Feedback', allowMaximize: false, showClose: true, width: 502, height: 295 }; SP.UI.ModalDialog.showModalDialog(o); }) ();"/>
</CustomAction>
</Elements>
-------------------------End Script------------------------
This piece of code adds a feedback menu in sharepoint welcome menu.The custom action id is telling the system where to add the menu. The image URL is the icon that is displayed in the menu. I am using a JavaScript to open a sharepoint modal popup window displaying the feedback form.
Step 5:
Open up the design of the application page. Add a dropdown control named feedbacktype and multiline textbox named feedback description. add two buttons for sumitting the feedback and other for cancel. The end result that i created looked like this...
Add following codes for populating the feedback type.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
ddl_Feedbacktype.Items.Add("--SELECT--")
ddl_Feedbacktype.Items.Add("Enhancement")
ddl_Feedbacktype.Items.Add("Complaint")
ddl_Feedbacktype.Items.Add("Appreciation")
ddl_Feedbacktype.Items.Add("Error")
End Sub
For cancel button add the following codebehind
Private Sub Btn_Cancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn_Cancel.Click
Try
Dim _Context As HttpContext = HttpContext.Current
If HttpContext.Current.Request.QueryString("IsDlg") IsNot Nothing Then
_Context.Response.Write("<script 'text/javascript'>window.frameElement.cancelPopUp();</script>")
_Context.Response.Flush()
_Context.Response.End()
End If
Catch ex As Exception
End Try
End Sub
For submit button add the following code
Private Sub Btn_Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn_Submit.Click
Try
If IsPostBack Then
If Not Page.IsValid Then Exit Sub
End If
'Check if the lists exits or else create it
Dim _Lists As SPList = SPContext.Current.Site.RootWeb.Lists.TryGetList("Feedback")
'Insert the feedback
Dim _SPListItem As SPListItem = _Lists.Items.Add()
_SPListItem("FeedBack Type") = ddl_Feedbacktype.SelectedValue
_SPListItem("FeedBack Description") = FeedbackDesc.Text
_SPListItem("FeedBack From") = SPContext.Current.Web.CurrentUser.Name.ToString
_SPListItem.Update()
Dim _Context As HttpContext = HttpContext.Current
If HttpContext.Current.Request.QueryString("IsDlg") IsNot Nothing Then
_Context.Response.Write("<script 'text/javascript'>window.frameElement.commitPopup();</script>")
_Context.Response.Flush()
_Context.Response.End()
End If
Catch ex As Exception
End Try
End Sub
Step 6
Create a new list(custom list) called feedback and add following columns:
FeedBack Type:Single line of text
FeedBack Description:Multiple line of text
step 7
Obviously deploy the project. viola!!!...you have a new menu appended in the welcome menu
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
ddl_Feedbacktype.Items.Add("--SELECT--")
ddl_Feedbacktype.Items.Add("Enhancement")
ddl_Feedbacktype.Items.Add("Complaint")
ddl_Feedbacktype.Items.Add("Appreciation")
ddl_Feedbacktype.Items.Add("Error")
End Sub
For cancel button add the following codebehind
Private Sub Btn_Cancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn_Cancel.Click
Try
Dim _Context As HttpContext = HttpContext.Current
If HttpContext.Current.Request.QueryString("IsDlg") IsNot Nothing Then
_Context.Response.Write("<script 'text/javascript'>window.frameElement.cancelPopUp();</script>")
_Context.Response.Flush()
_Context.Response.End()
End If
Catch ex As Exception
End Try
End Sub
For submit button add the following code
Private Sub Btn_Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn_Submit.Click
Try
If IsPostBack Then
If Not Page.IsValid Then Exit Sub
End If
'Check if the lists exits or else create it
Dim _Lists As SPList = SPContext.Current.Site.RootWeb.Lists.TryGetList("Feedback")
'Insert the feedback
Dim _SPListItem As SPListItem = _Lists.Items.Add()
_SPListItem("FeedBack Type") = ddl_Feedbacktype.SelectedValue
_SPListItem("FeedBack Description") = FeedbackDesc.Text
_SPListItem("FeedBack From") = SPContext.Current.Web.CurrentUser.Name.ToString
_SPListItem.Update()
Dim _Context As HttpContext = HttpContext.Current
If HttpContext.Current.Request.QueryString("IsDlg") IsNot Nothing Then
_Context.Response.Write("<script 'text/javascript'>window.frameElement.commitPopup();</script>")
_Context.Response.Flush()
_Context.Response.End()
End If
Catch ex As Exception
End Try
End Sub
Step 6
Create a new list(custom list) called feedback and add following columns:
FeedBack Type:Single line of text
FeedBack Description:Multiple line of text
step 7
Obviously deploy the project. viola!!!...you have a new menu appended in the welcome menu
Now thats how it is done....
thank you guys...Enjoy
--By Bijesh
thank you guys...Enjoy
--By Bijesh