you can easily spot a list of metro style menu item which acting as the quick launch section when you can launch a site in sharepoint 2012. the following pic will show you what they looks like
currently they are three items in the list.
I will demonstrate on how to add more items to this list.
First click on the Page tab to get the page edit tool bar enable, then click on the Edit button to make the page in edit mode
then click on the Edit Web Part in the drop down menu to load the Web Part Property section.
Select the All Promotions Link from the dropdown list under Select View Field, then click on
the Apply Button to show the item list.
Now we can click on the edit link to make the list editable.
Then we need to fill the all the columns with require data. I strongly recommend to
use those pop under windows to fill the information. Otherwise you will receive an error
message when you try to set the summary view in the web part property window.
then click on the stop link to save the new item that I just added to the list.
here is the result after I fill up all the columns for my demo item.
Now we can follow step 1-3 to launch the web part property window, and select Titles view from dropdown list under Select View and click on the Apply Button
done you will see the Newly create item on the right hand side of the quick access panel.
a blog to share Microsoft technologies Azure, DotNet, SharePoint, SQL Server,JavaScript Framework: Node.JS, Angular, React
Friday, November 9, 2012
Wednesday, October 24, 2012
How to Log Error to File in VBScript
I am an OO developer, but sometime i need to lend a hand to help out the development in VBScript or VB.
Though VBScript is an aging language for me. I still need to pick it up and use it in the
development.
the Error Logger will give you great help in the development and production since the user will come up to you and say the application is not working or not properly working. you will first go to the error log folder and check if anything had been logged to the file.
the following a very simple one that i created in VB to allow user log the error when it is
being raised in the function.
// the constant for read write, append properties for file Open
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
//function to handle logging the error to file. the parameter FunctionName is the source
// causing the issue. the second paramenter Error is like Exception in C# stored all the information
//related to the error.
function LogErrorToFile(FunctionName,Error)
Dim fso, tf,logFilePath
logFilePath="C:\ErrorLogFolder\MyErrorFileName"& FormattedCurrentDate&".Log"
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(logFilePath) Then
Set tf = fso.OpenTextFile(logFilePath, ForAppending, TRUE)
else
Set tf = fso.CreateTextFile(logFilePath, True)
end if
tf.WriteLine("************************************************" & Now() & "********************************************************")
tf.WriteLine("Function: " & FunctionName )
tf.WriteLine("Error Numnber: " & CStr(Err.Number))
tf.WriteLine("Source: " & Err.Source)
tf.WriteLine("Detail Error Message:" & Err.Description)
tf.WriteLine("****************************************************************************************************************************")
tf.WriteBlankLines(1)
tf.Close
Set fso =nothing
End function
//helper function to format to the current date to
//yyyy_MM_dd
Function FormattedCurrentDate
currentDate = CDate(Date)
currentDay = DatePart("d", currentDate )
currentMonth = DatePart("m", currentDate )
currentYear = DatePart("yyyy", currentDate )
If currentDay < 10 Then
currentDay = "0" & currentDay
End If
If currentMonth < 10 Then
currentMonth = "0" & currentMonth
End If
FormattedCurrentDate= currentYear & "_" & currentMonth onth & "_" & currentDay
End Function
the example to see you how to use the Error Logger inside the function
function MyFunction
on Error Resume Next
// your logic here
if Err.Number <> 0 then
LogErrorToFile "MyFunction",Err
end if
end function
Though VBScript is an aging language for me. I still need to pick it up and use it in the
development.
the Error Logger will give you great help in the development and production since the user will come up to you and say the application is not working or not properly working. you will first go to the error log folder and check if anything had been logged to the file.
the following a very simple one that i created in VB to allow user log the error when it is
being raised in the function.
// the constant for read write, append properties for file Open
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
//function to handle logging the error to file. the parameter FunctionName is the source
// causing the issue. the second paramenter Error is like Exception in C# stored all the information
//related to the error.
function LogErrorToFile(FunctionName,Error)
Dim fso, tf,logFilePath
logFilePath="C:\ErrorLogFolder\MyErrorFileName"& FormattedCurrentDate&".Log"
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(logFilePath) Then
Set tf = fso.OpenTextFile(logFilePath, ForAppending, TRUE)
else
Set tf = fso.CreateTextFile(logFilePath, True)
end if
tf.WriteLine("************************************************" & Now() & "********************************************************")
tf.WriteLine("Function: " & FunctionName )
tf.WriteLine("Error Numnber: " & CStr(Err.Number))
tf.WriteLine("Source: " & Err.Source)
tf.WriteLine("Detail Error Message:" & Err.Description)
tf.WriteLine("****************************************************************************************************************************")
tf.WriteBlankLines(1)
tf.Close
Set fso =nothing
End function
//helper function to format to the current date to
//yyyy_MM_dd
Function FormattedCurrentDate
currentDate = CDate(Date)
currentDay = DatePart("d", currentDate )
currentMonth = DatePart("m", currentDate )
currentYear = DatePart("yyyy", currentDate )
If currentDay < 10 Then
currentDay = "0" & currentDay
End If
If currentMonth < 10 Then
currentMonth = "0" & currentMonth
End If
FormattedCurrentDate= currentYear & "_" & currentMonth onth & "_" & currentDay
End Function
the example to see you how to use the Error Logger inside the function
function MyFunction
on Error Resume Next
// your logic here
if Err.Number <> 0 then
LogErrorToFile "MyFunction",Err
end if
end function
Wednesday, October 17, 2012
How to use javascript to trigger the server side event
put the following javascript code in the Javascript file
use the html element change event to trigger the server side. we fill the date from or date to textbox,
the textbox change event will be fired in the client.we must force the change event to fire since we do not use keyboard to input the date, instead we selected the date from the slide out calendar. as a result the textbox is unable to capture the content change.
in aspx page
$(function () { var dates = $("#txtDateFrom, #txtDateTo").datepicker({ defaultDate: "+1w", changeMonth: true, changeYear: true, numberOfMonths: 1, onSelect: function (selectedDate) { var option = this.id == "txtDateFrom" ? "minDate" : "maxDate", instance = $(this).data("datepicker"), date = $.datepicker.parseDate( instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings); dates.not(this).datepicker("option", option, date); if (this.id == "txtDateFrom") { $("#txtDateFrom").change(); } else if (this.id == "txtDateTo") { $("#txtDateTo").change(); } } }); });
use the html element change event to trigger the server side. we fill the date from or date to textbox,
the textbox change event will be fired in the client.we must force the change event to fire since we do not use keyboard to input the date, instead we selected the date from the slide out calendar. as a result the textbox is unable to capture the content change.
$("#txtDateFrom").change();
in aspx page
<asp:textbox id="txtDateFrom" runat="server" AutoPostBack="true"
OnTextChanged="txtDateFrom_onTextChanged"></asp:textbox>
in the code behind file we need to implement the evnet
protected void txtDateFrom_onTextChanged(object sender, EventArgs e) { //your logic to implement here }
Thursday, September 20, 2012
How to quickly disable an asp.net button from client side
usually we will create a JavaScript function to handle the client side click event.
something like the following
In Client Side
function disableButton(buttnId) { document.getElementsByName(buttnId)[0].disabled = true; }
In Server Side
buttonControl.Attributes.Add("onclick", "this.disabled=true;");
In Design Mode
However we can do it very quick in the design mode, set its disabled attribute to be true at
onClientClick event.
OnClientClick="this.disabled=true;"
<asp:Button runat="server" ID="btnSubmit" Text="Submit Data"
OnClick="btnSubmit_Click" Enabled="false" OnClientClick="this.disabled=true;" />
I had found one serious issue during this implementation.
though i can disable the button to prevent the user double click on it.
However the server side event had been disabled as well. i believe when i disabled
the button in the client side. when page was not pushed back to the server.
then it will not execute the server side click event and force the page to refresh.
we must manually refresh the page on the client side.
the line of code will hook up the _doPostBack() event on the button control.
btnSubmit.Page.ClientScript.GetPostBackEventReference(btnSubmit,"")
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { btnSubmit.Attributes.Add("onclick", "javascript:" +btnSubmit.ClientID +".disabled=true;"
+btnSubmit.Page.ClientScript.GetPostBackEventReference(btnSubmit,"")); } }
when you click on the button, the exception will thrown immediately
the Error Message is "Microsoft JScript runtime error: The value of the property '__doPostBack'
is null or undefined, not a Function object"
you will find the solution from this link. Ensure that __doPostBack() function is implemented on the page
Thursday, September 6, 2012
First Sharepoint-Host app development in Sharepoint 2013 Beta
Finally i completed my very first app development in SharePoint 2013
when you start your first try, a few step follow in order to make your first development smooth.
First you must create a separate domain that different from your current Sharepoint
in my case, i have SP2013.Local to host my Sharepont 2013.
and I create a separate domain called sp2013app.com to host all the Sharepoint Host App.
please note that it also work if you create a sub-domain under SP2013.Local. I test it with a sub-domain apps.SP2013.Local
the following link will give you a very informative instruction to create the domain for your SharePoint Host App. it covered both the sub-domain case and a brand new domain case as well.
Setting up your App domain for SharePoint 2013
after you deploy the your app to SharePoint 2013 Developer Site which is ran under Developer site template. you must add a new key under the Lsa property. the new key will prevent the constant popup to ask for the credential.
when you start your first try, a few step follow in order to make your first development smooth.
First you must create a separate domain that different from your current Sharepoint
in my case, i have SP2013.Local to host my Sharepont 2013.
and I create a separate domain called sp2013app.com to host all the Sharepoint Host App.
please note that it also work if you create a sub-domain under SP2013.Local. I test it with a sub-domain apps.SP2013.Local
the following link will give you a very informative instruction to create the domain for your SharePoint Host App. it covered both the sub-domain case and a brand new domain case as well.
Setting up your App domain for SharePoint 2013
after you deploy the your app to SharePoint 2013 Developer Site which is ran under Developer site template. you must add a new key under the Lsa property. the new key will prevent the constant popup to ask for the credential.
Subscribe to:
Posts (Atom)