Skip to main content

Posts

Showing posts from September, 2013

update query in linq to sql

Hi Everyone, I'm going to share the code sample for update query in linq to sql in c# asp.net Today, I have a requirement to update the log details in the DB with respect to the UserId.   /// <summary>   ///  Update to user device access log table using linq to sql in c# .net   /// </summary>   using ( ExceptionLogDataContext dbContext = new ExceptionLogDataContext ())  {                 if (! string .IsNullOrEmpty(UserId))      {                     var IsExistedUser = ( from user in dbContext.UserDeviceAccessLogs               where user.UserId == Convert .ToInt32(UserId)                select user).FirstOrDefault();         if (IsExistedUser.UserId != null )         {                   IsExistedUser.CreatedDate = DateTime .UtcNow;                   IsExistedUser.DeviceType = DeviceType;                   IsExistedUser.LastAccessed = DateTime .UtcNow;                   IsExistedUser.LatestAccessIP = AccessIPAddres

insert query in linq to sql in c#

Hi Everyone, I'm going to share the code sample for insert query in linq to sql in c# asp.net Today, I have a requirement to insert the log details in the DB using asp.net, entity framework and c# as well. /// <summary> /// Insert the user device logs details using to linq to sql with c# .net /// </summary> using ( ExceptionLogDataContext dbContext = new ExceptionLogDataContext ()) {                        if (! string .IsNullOrEmpty(UserId))             {                              // create the table object.                   UserDeviceAccessLog AccessLog = new UserDeviceAccessLog ();                   AccessLog.CreatedDate = DateTime .UtcNow;                   AccessLog.UserId = Convert .ToInt32(UserId);                   AccessLog.ApplicationVersion = "5S.1.0" ;                   AccessLog.AppName = "DempApp" ;                   AccessLog.DeviceId = "iPhone" ;                   AccessLog

create dynamic table in asp.net c#

Hello Everyone, I'm going to share the code sample for  create dynamic table using asp.net c# . Today, i have a requirement to create a  dynamic table  with the help of user inputs( number of rows and columns) on click on create table button. These look like the below: In the 1st step I'm going to share the code sample for .aspx page < asp : Content ID ="BodyContent" runat ="server" ContentPlaceHolderID ="MainContent">     < div >         No. of Rows: < asp : TextBox ID ="txt_TableRows" runat ="server" Width ="65px" /> &nbsp;         No. of Cols: < asp : TextBox ID ="txt_TableCols" runat ="server" Width ="65px" /> < br />         < asp : CheckBox ID ="chk_CellBorder" runat ="server" Text ="Broder of cells" /> &nbsp;         < asp : Button ID ="btn

web api in mvc 4

Hi All,  I'm going to share the code sample for web api in mvc 4 using  $.post() and $.getJSON() methods. Today's, i have requirement to logging to errors using "web api in mvc 4 and jquery". In the 1st step, code sample fo r $.post() and $.getJSON() methods $.post()  method //POST() method used to post exceptions and Log too large data in the DB.    $.post(‘ /ExceptionLog/Logger ’, { requestUrl: logsUrl, browserInfo: browser_version, cookiesInfo: cookies, error: errorInfo })    .done( function (data) {        console.log(data);     })    .fail( function (jqXHR, textStatus, errMsg) {        console.log( 'Errors: ' + errMsg);     }); $.getJSON()  method     //getJSON() method used to get exceptions and Log limited data in the DB.     $.getJSON (‘ /ExceptionLog/Logger ’, { userId: Id})    .done( function  (data) {        console.log(data);     })    .fail( function  (jqXHR, textStatus, errMsg) {        console.log( &

detection browsers and version in jquery asp.net

Hi All,  I'm going to share the code sample for find to or detect to browsers and browsers version using jquery asp.net . The code sample for find browsers using jquery < script type ="text/javascript">  function getCurrentBrowsers_Name () {     var Names = navigator.appName;     var users = navigator.userAgent;     var temp;     var Matchs = users.match(/(opera|chrome|safari|firefox|ie)\/?\s*(\.?\d+(\.\d+)*)/i);     if (Matchs && (temp = users.match(/version\/([\.\d]+)/i)) != null) Matchs[2] = temp[1];     Matchs = Matchs ? [Matchs[1], Matchs[2]] : [Names, navigator.appVersion, '-?'];     return Matchs[0]; } var   getCurrentBrowser =  getCurrentBrowsers_Name (); </ script> The code sample for find browsers version on using jquery < script   type ="text/javascript">  function getCurrentBrowsers_Version () {     var Names = navigator.appName;     var users = navigator.userAgent;    

enter key press event in jquery asp.net

Hi All,  I'm going to share the code sample for  enter key press event in asp.net using jquery. I have an requirement to implement to log-in users after  enter key press on log-in button in asp.net. In the 1st step, code sample for .aspx Email : <asp:TextBox ID= "txtEmail" runat= "server" /> Password: <asp:TextBox ID= "txtPassword" runat= "server" /> <asp:Button ID= "btnSignIn" runat= "server" Text= "Login" /> In the 2nd step, code sample for jquery < script type ="text/javascript">   $(document).ready( function (){      $(window).keydown( function (e){         if (e.keyCode == 13)  {            $( “#<% btnSignIn.ClientID %>”) .click();  }      });   }); </ script >

Enter Key Press TextBox in ASP.Net

Today, i have an requirement to implement to  enter key press event on a log-in page in asp.net , these log-in screen is display as popup screen. I'm going to share the code sample for enter key press event code on popup. In my application display div as a popup. The .net  already have the enter key press event which are given below code  i.e. <div onkeypress= "return WebForm_FireDefaultButton(event, '<%=                            btnSignIn.ClientID %>')" > </div>  Note:  WebForm_FireDefaultButton() method is use to set default button method, provided by .net not needed to other code here. I have tested to all of browsers its working fine to me.

knockout js attr binding

Hello Everyone, I'm going to share the code sample for attr binding in knockoutjs . The attr Binding In the 1st  step  :   code sample for v iew < a data-bind =" attr: { href: myUrl, title: myDetail} ">     //Todo: Something content here.. </ a > In the 2nd step: code sample for v iew-Model < script type ="text/javascript">     var myViewModel = {         myUrl: ko.observable( " http://aspdotnetblogspot.blogspot.in/ " ),         myDetail: ko.observable( "This is my code sample blog" )     }; </ script >

knockout js if ifnot else binding

Hello Everyone, I'm going to share the code sample for if bindings in knockoutjs and ifnot bindings in knockoutjs . In the 1st s tep   : code sample for if binding in the view The " if " binding    <!-- ko if: totalEmployee -->         Total Employee( <!--ko text:  totalEmployee  --><!--/ko--> )     <!-- /ko --> code sample for  ifnot binding  in the  view The " ifnot " binding    <!-- ko ifnot: totalEmployee -->         No Employee.    <!-- /ko --> In the 2nd s tep   :  code sample for  view-Model < script type ="text/javascript">     var   totalEmployee =   ko.observableArray([            { Id: "001", type: "JEE" },           { Id: "002", type: "SSE" }     ]); </ script >

knockoutjs custom bindings

Hi, i'm going to share the code sample for  custom bindings in knockoutjs I have an requirement to count and display to total employees. if have more then zero employee in employee-list, count and display. In the 1st step, code sample for view model. < script type ="text/javascript"> // declare observable array var totalEmployee = ko.observableArray([]); try {     //get employee list form search employee method.     var empList = searchEmployee();     //push all items in totalEmployee array collection.     if (empList !== undefined && empList.count > 0) {         $.each(empList, function (i, v) {             totalEmployee.push({ Id: v.empId, EmpName: v.empName });         });     }; } catch (e) {               //Toto: insert to logg, if any.               console.log(e.stack); } finally { } </ script > In the 2nd step, code sample for view. <!-- ko if: totalEmployee -->