Thursday, April 30, 2015

jQuery and JavaScript Coding: Examples and Best Practices - RULE #1: SEPARATE JAVASCRIPT FUNCTIONALITY

CrossBad markup:
Never include Javascript events as inline attributes. This practice should be completely wiped from your mind.
<a onclick="doSomething()" href="#">Click!</a>
TickGood markup:
All Javascript behaviours should be included in external script files and linked to the document with a <script> tag in the head of the page. So, the anchor tag would appear like this:
<a href="backuplink.html" class="doSomething">Click!</a>
And the Javascript inside the myscript.js file would contain something like this:
...

$('a.doSomething').click(function(){
 // Do something here!
 alert('You did something, woo hoo!');
});
...

Wednesday, April 29, 2015

SQL Insert mutiple values to table

Database - Insert into mst_type(work_type_id,sub_work_type,record_status,create_user,create_stamp,update_user,update_stamp)
values (9,'Primary','A','system',GETDATE(),'system',GETDATE()),
(9,'Center','A','system',GETDATE(),'system',GETDATE()),
(9,'Medical','A','system',GETDATE(),'system',GETDATE()),
(9,'Staff','A','system',GETDATE(),'system',GETDATE()),
(9,'Aanganwadi','A','system',GETDATE(),'system',GETDATE()),
(9,'School','A','system',GETDATE(),'system',GETDATE()),
(9,'Village','A','system',GETDATE(),'system',GETDATE()),
(9,'Samajik Sabhagruha','A','system',GETDATE(),'system',GETDATE()),
(9,'Shopping Center Building','A','system',GETDATE(),'system',GETDATE()),
(9,'Veternary Hospital','A','system',GETDATE(),'system',GETDATE()),
(9,'Mahila Work Shed Building','A','system',GETDATE(),'system',GETDATE()),
(9,'Product Selling Stall','A','system',GETDATE(),'system',GETDATE()),
(9,'Office Building','A','system',GETDATE(),'system',GETDATE()),
(9,'Staff Quarter Building','A','system',GETDATE(),'system',GETDATE()),
(9,'Smashan Bhumi','A','system',GETDATE(),'system',GETDATE()),
(9,'Toilet Blocks','A','system',GETDATE(),'system',GETDATE()),
(10,'Major Bridge','A','system',GETDATE(),'system',GETDATE()),
(10,'Minor Bridge','A','system',GETDATE(),'system',GETDATE()),
(10,'Culverts','A','system',GETDATE(),'system',GETDATE())

SQL add column to table


alter table trn
add sub_wo int

Tuesday, April 28, 2015

asp.net dropdown change hide show html div

   $('#<%= ddl.ClientID %>').change(function () {
                var selectedvalue = $(this).val();
             
                if (selectedvalue == 1) {
                    $("#divContractorName").show();
                }
                else {
                    $("#divContractorName").hide();
                }
            });


   <div id="divContractorName" class="wd33percommuNew lFloat " style="display: none;">
                                Hello world
                                </div>

SQL if value is not passing to stored procedure make it null

1) If Name field in form is empty then stored procedure will give error because it is expecting parameter name.

2) So to resolved this error modify stored procedure like below

ALTER procedure procedrename
(
   @name nvarchar = null
)

SQL get stored procedure body by name

sp_helptext yourStoredProcedureName

assigning Null value to datetime in C#

Since DateTime is a value type (like int), a Null value cannot be assigned to it.

DateTime? dateSample;
dateSample.Value = null;
//or 
Nullable<DateTime> dateSample2;
dateSample2.Value = null;