when i implemented an update Functionality using asp.net.
I got a very strange return -1 in each execution. since I had a conditional check to verify each update.
As I know that sqlComm.ExecuteNonQuery() return the number of rows being affected by the Update, Insert operation.
when i went back to look at my Stored-Procedure i found that SET NOCOUNT ON; in my Stored Procedure.
Alter PROCEDURE [dbo].[Customer_Data_Master_Upd]
@Prospect nvarchar(10)
AS
BEGIN
SET NOCOUNT ON;
Update Customer_Data_Master
Set Status='N'
where LCDGCC =@Prospect
END
after I commented out the line Set NOCOUNT ON
My conditional check works as plan. In My opinion, the Set NOCOUNT On should only be enable in Select statment to improve performance.
a blog to share Microsoft technologies Azure, DotNet, SharePoint, SQL Server,JavaScript Framework: Node.JS, Angular, React
Wednesday, September 28, 2011
Monday, September 26, 2011
How to Design and Configure Custom View of A list in Sharepoint 2010
in Sharepoint 2010 we can use a webpart to display the content of the sharepoint List library.
the default list view will show the column header and a checkbox when you show the list content with a webpart.
in my case i only want to show the content without any header and checkbox selection, then i decide to create a custom listview to replace the default one.
here is the step to create a custom listview:
1. Click on the CreateView Button in the Ribbon ToolBar
2. Click on the Standard View link Buton from the Choose View Format
3. selected all the columns that you want to show to the user.
4. unchecked the checkbox from the Tabular View Section
4. Change the default to NewsLetters No Lines in the Style Section.
5. Click Ok to finish the Custom List View creations.
6. choose the newly create Custom ListView in the List Webpart.
the default list view will show the column header and a checkbox when you show the list content with a webpart.
in my case i only want to show the content without any header and checkbox selection, then i decide to create a custom listview to replace the default one.
here is the step to create a custom listview:
1. Click on the CreateView Button in the Ribbon ToolBar
2. Click on the Standard View link Buton from the Choose View Format
3. selected all the columns that you want to show to the user.
4. unchecked the checkbox from the Tabular View Section
4. Change the default to NewsLetters No Lines in the Style Section.
5. Click Ok to finish the Custom List View creations.
6. choose the newly create Custom ListView in the List Webpart.
Tuesday, September 20, 2011
use Validator and ValidationSummary in ASP.Net Validation
Today I implemented a form for user submit since i need to ensure all the required fields are filled by the user
I use RequiredFieldValidator to control the Mandatory fields validation.
I use RequiredFieldValidator to control the Mandatory fields validation.
the code works perfectly fine, all the erorr message displayed after user click
submit button.
after i added another panel with another submission sesseion.
no matter which button is trigger
all the error messages are shown. there is a ValidationGroup Property
in control which is availble for .net 3.5 and later. when the button is clicked
by the user, only the specific Validation Group that specified in the Button
validationGroup Property will be triggered and validated. All the Error Message
will only shown
here is the sample code:
<asp:ValidationSummary ID="ValidationSummaryControl" runat="server"
HeaderText="Validation Errors:" ValidationGroup="RateSubmit" />
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
HeaderText="Validation Errors:" ValidationGroup="ExpenseSubmit" />
<td class="style2"> <asp:Label runat="server" ID="lblDateFrom" Text="Date From: " Font-Bold="true">
</asp:Label></td> <td class="style3"> <asp:TextBox runat="server" ID="txtDateFrom"></asp:TextBox> <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator3" Display="None"
ErrorMessage="Please fill Expense Date From" ControlToValidate="txtDateFrom"
ValidationGroup="ExpenseSubmit" ></asp:RequiredFieldValidator>
<asp:Button runat="server" ID="btnExpenseSubmit" Text="Submit" causesvalidation="true"
onclick="btnExpenseSubmit_Click" ValidationGroup="ExpenseSubmit" /></td>
<td class="style2"> <asp:Label runat="server" ID="Label3" Text="Subaru Milage Rate: " Font-Bold="true"></asp:Label></td> <td class="style3"> <asp:TextBox runat="server" ID="txtMilagRate" ValidationGroup="RateSubmit"></asp:TextBox> <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator10" Display="None"
ErrorMessage="Please fill Milage Rate Field" ControlToValidate="txtMilagRate"
ValidationGroup="RateSubmit"></asp:RequiredFieldValidator> </td> </tr> <td class="style5" align="right"> <asp:Button runat="server" ID="btnRateSubmit"
Text="Submit" onclick="btnRateSubmit_Click"
ValidationGroup="RateSubmit" CausesValidation="true" /></td>
Tuesday, September 13, 2011
calling Javascript function in asp.net 4.0 master page in LookServer
when you have a asp.net applicaiton with master page enable,
you probably will try to call it in the body onload event from the master page.
here is the simple test javasript function embedded at the header section in the html code
<script language="javascript" type="text/javascript">
function load()
{
alert("Page is loaded");
}
</script>
you should encounter the following error
<body id="PageBody" runat="server" onload="load();">
Error:CS1061: 'ASP.views_shared_lookserver_master' does not contain a definition for 'load' and no extension method 'load' accepting a first argument of type 'ASP.views_shared_lookserver_master' could be found (are you missing a using directive or an assembly reference?)
<body id="PageBody" runat="server" onload="Javascript:load();">
Error:Compiler Error Message: CS1026: ) expected
i believe that the look server master page did not like the javascript call with the body onload event.
i google it and i got some good idea from this page
instead of executing javascript functio from the body onload event. the function will be called from the window.onload event.
here is the change of javascript
before :
<script language="javascript" type="text/javascript">
function load()
{
alert("Page is loaded");
}
</script>
<body id="PageBody" runat="server" onload="load();">
after:
<script type="text/javascript">
window.onload = MyInit();
function MyInit() {
alert("Page is loaded");
}
</script>
<body id="PageBody" runat="server">
you will see the pop window when the page is loading. cheers..i hope this will help you when you need
to execute a javascript function during the page loading
Update:
when i test the script i got an Error Message (not implement in IE)
here is the fix
Before:
<script type="text/javascript">
window.onload = MyInit();
function MyInit() {
alert("Page is loaded");
}
</script>
Current:
<script type="text/javascript">
window.onload =function () {
alert("Page is loaded");
}
</script>
you probably will try to call it in the body onload event from the master page.
here is the simple test javasript function embedded at the header section in the html code
<script language="javascript" type="text/javascript">
function load()
{
alert("Page is loaded");
}
</script>
you should encounter the following error
<body id="PageBody" runat="server" onload="load();">
Error:CS1061: 'ASP.views_shared_lookserver_master' does not contain a definition for 'load' and no extension method 'load' accepting a first argument of type 'ASP.views_shared_lookserver_master' could be found (are you missing a using directive or an assembly reference?)
<body id="PageBody" runat="server" onload="Javascript:load();">
Error:Compiler Error Message: CS1026: ) expected
i believe that the look server master page did not like the javascript call with the body onload event.
i google it and i got some good idea from this page
instead of executing javascript functio from the body onload event. the function will be called from the window.onload event.
here is the change of javascript
before :
<script language="javascript" type="text/javascript">
function load()
{
alert("Page is loaded");
}
</script>
<body id="PageBody" runat="server" onload="load();">
after:
<script type="text/javascript">
window.onload = MyInit();
function MyInit() {
alert("Page is loaded");
}
</script>
<body id="PageBody" runat="server">
you will see the pop window when the page is loading. cheers..i hope this will help you when you need
to execute a javascript function during the page loading
Update:
when i test the script i got an Error Message (not implement in IE)
here is the fix
Before:
<script type="text/javascript">
window.onload = MyInit();
function MyInit() {
alert("Page is loaded");
}
</script>
Current:
<script type="text/javascript">
window.onload =function () {
alert("Page is loaded");
}
</script>
Thursday, September 1, 2011
Integrate jCarouselLite into sharepoint 201 Content editor webpart. as Image Slider
since sharepoint 2010 support jquery as client size programing.. it is conveniently to integrate the jquery to improve user experience.
you can find one image slider from this link http://www.gmarwaha.com/jquery/jcarousellite/
though the web site offer free download and demo to show you use to this handy plugin. however, you still
a little tweak to make it work in your sharepoint 2010 site. the demo only give you a very simple code.
you need to set all the options (i highlight all the options that need to configure) before the slider can function in sharepoint 2010 web site.
here is the code that working fine in my website you can just copy the code and change the anchor url reference and image path to your specific case. then image slider will proper setup and running in your site.
<script type="text/javascript" src="../jcarousellite_1.0.1.js"></script>
<script type="text/javascript">
$(function() {
$(".MyClass").jCarouselLite({
btnNext: ".next",
btnPrev: ".prev",
btnGo: null,
mouseWheel: false,
auto: null,
speed: 1000,
easing: null,
vertical: false,
circular: true,
visible: 5,
start: 0,
scroll: 1,
});
});
</script>
<style type="text/css">
img {
margin-left:3px;
margin-right:3px;
}
#middleContent {
float:left;
width:595px;
}
#leftContent {
margin-top:10px;
float:left;
width:35px;
}
#rightContent {
margin-top:10px;
float:left;
width:10px;
}
</style>
<div id="leftContent">
<button class="prev"><<</button>
</div>
<div class="MyClass" id="middleContent">
<ul>
<li><a href="url1" target="_blank" ><img src="MyImage1" alt="" width="200" height="50" ></a></li>
<li ><a href="url2" target="_blank" ><img src="MyImage2" alt="" width="200" height="50" ></a></li>
<li ><a href="url3" target="_blank" ><img src="MyImage3" alt="" width="200" height="50" ></a></li>
<li ><a href="url4" target="_blank" ><img src="MyImage4" alt="" width="185" height="44" ></a></li>
<li ><a href="url5" target="_blank" ><img src="MyImage5" alt="" width="200" height="50" ></a></li>
</ul>
</div>
<div id="rightContent">
<button class="next">>></button>
</div>
you can find one image slider from this link http://www.gmarwaha.com/jquery/jcarousellite/
though the web site offer free download and demo to show you use to this handy plugin. however, you still
a little tweak to make it work in your sharepoint 2010 site. the demo only give you a very simple code.
you need to set all the options (i highlight all the options that need to configure) before the slider can function in sharepoint 2010 web site.
here is the code that working fine in my website you can just copy the code and change the anchor url reference and image path to your specific case. then image slider will proper setup and running in your site.
<script type="text/javascript" src="../jcarousellite_1.0.1.js"></script>
<script type="text/javascript">
$(function() {
$(".MyClass").jCarouselLite({
btnNext: ".next",
btnPrev: ".prev",
btnGo: null,
mouseWheel: false,
auto: null,
speed: 1000,
easing: null,
vertical: false,
circular: true,
visible: 5,
start: 0,
scroll: 1,
});
});
</script>
<style type="text/css">
img {
margin-left:3px;
margin-right:3px;
}
#middleContent {
float:left;
width:595px;
}
#leftContent {
margin-top:10px;
float:left;
width:35px;
}
#rightContent {
margin-top:10px;
float:left;
width:10px;
}
</style>
<div id="leftContent">
<button class="prev"><<</button>
</div>
<div class="MyClass" id="middleContent">
<ul>
<li><a href="url1" target="_blank" ><img src="MyImage1" alt="" width="200" height="50" ></a></li>
<li ><a href="url2" target="_blank" ><img src="MyImage2" alt="" width="200" height="50" ></a></li>
<li ><a href="url3" target="_blank" ><img src="MyImage3" alt="" width="200" height="50" ></a></li>
<li ><a href="url4" target="_blank" ><img src="MyImage4" alt="" width="185" height="44" ></a></li>
<li ><a href="url5" target="_blank" ><img src="MyImage5" alt="" width="200" height="50" ></a></li>
</ul>
</div>
<div id="rightContent">
<button class="next">>></button>
</div>
Subscribe to:
Posts (Atom)