Search This Blog

Monday, March 18, 2019

How to scroll up the page using jquery

Welcome to  designer dairy blog, here we are going to  discuss how to scroll up the page using jquery.

Step1:

In my scenario, I have the fixed header and the content area consists of the anchor tag link. when the user clicks the link it should be moved to appropriate section.

Step2:



Script:


<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>

<script>

$(function(){

$('a[href^="#"]').not('[href=#]').click(function(e){

var anchorTag=$(this).attr('href').replace('.','\\.');

$('html, body').animate({scrollTop: $(anchorTag).offset().top - ($('.searchbar').outerHeight()+5) }, 1000);

return false

;

}

);

Step3:

Thanks for reading my article.Stay Tune on www.webdesignersdairy.com  for more updates on Jquery.

Sunday, December 16, 2018


Datatype -  Strongly datatype

Basis of memory allocation, data types are classified in two types

1. Value Types - which will allocated the value in stack. = >  int a =10;
2. Reference Types  - which will store the value in the Heap but store the reference in Stack  = String = "Tp";

Stack -  all the memory location of program like method, variable all will store in stack.

Stack  - int a =10  (value types)  S (Reference type)
Heap -                 Tp




Bulk value will be taken care by heap.
Stack stores the fixed values if u store all the values in
stack it will get overloaded and proogram will get terminate so that we are using Heap

 string f = c ?? "Faizal"; // coalescing operator ??

1. Arithmetic Operators =>  + , - , *, /,  % (modulus) , ++, -- increase and decrease by1

Used for mathematical Calculation

2. Relational / Comparison operators =>  ==, !=, >, <, >=, <=

Returns the Boolean value after comparing

3. Logical Operation=> delays with boolean and return boolean too
 &&  - True or false
 ||  - True or false

 ! - if its true will return false
      if its flas ewill return true

Ternary operators  three operands

string s = num% 2 ==0 ? " even"  : "odd";

Friday, December 14, 2018

What is IL Code, CLR, CTS, CLS & JIT?

Step:1
Welcome to designer blog, Here we are going to discuss about  What is IL Code, CLR, CTS, CLS & JIT?

Step:2

IL (Intermediate Language) - Half compile code  (either it be Vb.net or C# Sharp)

CLR - Common Language Run-time. 

Programmers are use high-level languages like C# and  C++  etc ... Default Compilers,  compile  C#programming to machine language( 0 and 1). so that operating system can understand.Once it compile, it will produce Assemble( .dll and .exe file).

There is one dis-advantage of default compiler is it runs only in Window Server not in Linux server

To overcome this problem we are using ".Net Application" it compiles the C#,Vb.net and other languages and  produce assembly(.Dll or EXE) in IL code  (Intermediate language).. CLR  is the heart of the .net application which  converts IL Code to  Native code so that operating system can understand



IL   -  CLR (Windows, Linux) -  Operating sytem
         IL

        JIT Compiler(Just In-Time Compiler )-  in CLR converts, the IL into native code which can then be run on the                                                underlying operating system.
         Native Code
            "
          OS

CLR is introduced  runtime environment which converts IL Code to Native code suing JIT Compiler ..
Native code =which unix operating sytem ( o and 1) can understand

 Converts Intermediate language to Native code  where operating system can understand

CTS -  Common Type System -  Common Datatype platform 

(either you write your code in Vb.net or C# Sharp)  it will have the common data type example
Dim i As Integer -  Vb.net
int i = 1;             -      both will have common data type int 32


CLS - Common language Specification - (Data Access Layer)
Set of rules or guidelines to following and for referencing to another .net language

You write your code in C# Sharp and it consume in Vb.net that is called as Common language Specification by following CLS










Thursday, December 13, 2018

Get title attribute using each in Jquery



$("#SiteMap1 a#lnkPage").each(function() {
console.log($(this).attr('title'));
var title = $(this).attr('title');
if (title != null)
{
debugger;
$("#title").text(title);
}

Wednesday, October 24, 2018

ASP.Net Membership and Role Provider

Step:1
Welcome to designer blog, Here we are going to discuss about  how to provide ASP.Net Membership and Role Provider.

Step:2

Install the aspnet_regsql.exe by going to this location path :

(C:\Windows\Microsoft.NET\Framework[framework version]\aspnet_regsql) 

Example:

(C:\Windows\Microsoft.NET\Framework\v4.0.30319)

Step:3

After installing the Aspnet_regsql.exe. If you open the SQL Server, you can find the ASP.Net Membership Tables is installed in the SQL server.

Step:4

Database provides the API calls to invoke installed  tables in SQL server. Open the web.config file and declare the connection String, Membership and Role Manager.

Below are the declaration code:

  <connectionStrings>
    <add name="LocalSqlServer3" connectionString="Data Source=localhost;Initial Catalog=credentials;Integrated Security=True;Pooling=False"/>

  </connectionStrings>

 <membership>
        <providers>
          <remove name="AspNetSqlMembershipProvider"/>
          <add name="AspNetSqlMembershipProvider"
          type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
          connectionStringName="LocalSqlServer3"
          enablePasswordRetrieval="false"
          enablePasswordReset ="true"
          applicationName="/"         
          minRequiredPasswordLength="7"/>
        </providers>
      </membership>

      <roleManager enabled="true" >
        <providers>
          <clear/>
          <add name="AspNEtSqlRoleProvider"
              connectionStringName="LocalSqlServer3"
               applicationName="/"
              type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        </providers>
      </roleManager>

Step5:

Create a login screen and drag and drop the login and register wizard UI Controls

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="CustomerdataEntryWeb.Login" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="font-family:Arial">
<table style="border: 1px solid black">
    <tr>
        <td colspan="2">
            <b>Login</b>
        </td>
    </tr>
    <tr>
        <td>
            User Name
        </td>    
        <td>
            :<asp:TextBox ID="txtUserName" runat="server">
            </asp:TextBox>
        </td>    
    </tr>
    <tr>
        <td>
            Password
        </td>    
        <td>
            :<asp:TextBox ID="txtPassword" TextMode="Password" runat="server">
            </asp:TextBox>
        </td>    
    </tr>
    <tr>
        <td>
                    
        </td>    
        <td>
            <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" />
        </td>    
    </tr>
</table>
<br />
<a href="Registration/Register.aspx">Click here to register</a> 
if you do not have a user name and password.
</div>
        <asp:Login ID="Login1" runat="server" OnAuthenticate="Login1_Authenticate">
        </asp:Login>
        <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" OnCreatedUser="CreateUserWizard1_CreatedUser">
            <WizardSteps>
                <asp:CreateUserWizardStep runat="server" />
                <asp:CompleteWizardStep runat="server" />
            </WizardSteps>
        </asp:CreateUserWizard>
    </form>
</body>
</html>

Step6:

Include the namespace "using System.Web.Security" and write the below code in the code behind for Login and Register buttons

Code Behind:

   protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            if(Membership.ValidateUser(Login1.UserName, Login1.Password))
            {
                Response.Redirect("welcome.aspx");
            }
        }

        protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
        {
            MembershipCreateStatus status;
            Membership.CreateUser(CreateUserWizard1.UserName,
                                     CreateUserWizard1.Password,
                                    CreateUserWizard1.Email,
                                    CreateUserWizard1.Question,
                                    CreateUserWizard1.Answer,
                                    true,
                                    out status);

            if(status != MembershipCreateStatus.Success)
            {
                status.ToString();
            }
            else
            {
                Response.Write("Created");
            }
        }

Step7:

Thanks for reading article.Stay Tune on www.webdesignersdairy.com  for more updates.


Enjoy Folks

Tuesday, October 16, 2018

Connection between ADO.net to SQL Server.

Step1:

Welcome to designer blog, Here we are going to discuss about  how to connect ADO.net  to Sql Server.

Step2:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
namespace DataAccess
{
    public class clsSqlServer
    {

        public DataSet getCustomers()
        {
            // open a connection
            string Connectionstring = ConfigurationManager.ConnectionStrings["DbConn"].ToString();
            SqlConnection objConnection = new SqlConnection(Connectionstring);
            objConnection.Open();

            // Fire the command object
            // Command -- SQL - SQl server
            SqlCommand objCommand = new SqlCommand("Select * from Customer", objConnection);
            DataSet objDataset = new DataSet();
            SqlDataAdapter objAdapter = new SqlDataAdapter(objCommand);

            objAdapter.Fill(objDataset);


            // Close the connection
            objConnection.Close();
            return objDataset;
        }
        public DataSet getCustomers(string CustomerCode)
        {
            // open a connection
            string Connectionstring = ConfigurationManager.ConnectionStrings["DbConn"].ToString();
            SqlConnection objConnection = new SqlConnection(Connectionstring);
            objConnection.Open();

            // Fire the command object
            // Command -- SQL - SQl server
            SqlCommand objCommand = new SqlCommand("Select * from Customer where CustomerName='"
                                  + CustomerCode + "'",
                                  objConnection);
            DataSet objDataset = new DataSet();
            SqlDataAdapter objAdapter = new SqlDataAdapter(objCommand);

            objAdapter.Fill(objDataset);


            // Close the connection
            objConnection.Close();
            return objDataset;
        }

        public bool InsertCustomer(string strCustomerName,
                                    string Country,
                                    string Gender,
                                    string Hobbies,
                                    bool Status)
        {
            // Open connection
            string Connectionstring = ConfigurationManager.ConnectionStrings["DbConn"].ToString();
            SqlConnection objConnection = new SqlConnection(Connectionstring);
            objConnection.Open();
            try
            {
                
                // Command insert fire
                string strInsertCommand = "insert into Customer values('"
                                                    + strCustomerName + "','"
                                                    + Country + "','"
                                                    + Gender + "','"
                                                    + Hobbies + "',"
                                                    + Convert.ToInt16(Status) + ")";

                
                SqlCommand objCommand = new SqlCommand(strInsertCommand, objConnection);
                objCommand.ExecuteNonQuery();
                // close connection
                
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
            finally
            {
                objConnection.Close();
            }
           
        }

        public bool UpdateCustomer(string strCustomerName,
                                    string Country,
                                    string Gender,
                                    string Hobbies,
                                    bool Status)
        {
            // Open connection
            string Connectionstring = ConfigurationManager.ConnectionStrings["DbConn"].ToString();
            SqlConnection objConnection = new SqlConnection(Connectionstring);
            objConnection.Open();
            // Command insert fire
            string strUpdateCommand = "Update Customer set CustomerName='"
                                                + strCustomerName + "',Country='"
                                                + Country + "',Gender='"
                                                + Gender + "',Hobbies='"
                                                + Hobbies + "',Married="
                                                + Convert.ToInt16(Status) + " where CustomerName='" + strCustomerName + "'";


            SqlCommand objCommand = new SqlCommand(strUpdateCommand, objConnection);
            objCommand.ExecuteNonQuery();
            // close connection
            objConnection.Close();
            return true;
        }

        public bool DeleteCustomer(string strCustomerName)
        {
            string Connectionstring = ConfigurationManager.ConnectionStrings["DbConn"].ToString();
            SqlConnection objConnection = new SqlConnection(Connectionstring);
            objConnection.Open();

            // Fire the command object
            // Command -- SQL - SQl server
            SqlCommand objCommand = new SqlCommand("delete from Customer where CustomerName='"
                                    + strCustomerName + "'",
                                    objConnection);

            objCommand.ExecuteNonQuery();
            objConnection.Close();
            return true;
        }
    }
}

Step3:

Enjoy Folks

Monday, October 8, 2018

How to bind the api data by using datatables plugins



Step1:

Welcome to the designer blog, here we are going to discuss,  How to bind the API data in the data tables plugins

Step2:

Below is the function where the API is called and data is successfully fetched and append in the <table id="populardoc">


<Script>
function getdoclibhits()
 {
 var totalcnt=0;
  $.ajax({
 url: "http://in-bomspsuwv003:8182/sites/advisoryindiakm/_api/search/query?querytext='{1C5FC323-4E36-44CA-8390-987189C28B1F}'&rowlimit=10000&sortlist='ViewsLifeTime:descending'",
 type: "GET",
 headers: {
 "Accept": "application/json;odata=verbose"
 },
 success: function(data) {
 //log the json to analyze and visualize
 console.log(data);
 var items=data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results;
 //log the actual 10 items that is going to be displayed
 console.log(items);
 //$('#popular').append('<table><tr><th>Doc Name</th><th>No. of Hits</th></tr>');
 $.each(items, function(index, item) {

 var ret= items[index].Cells.results[6].Value;
 //replacing any spaces in the URL
 var itemlinks= ret.replace(/ /g,"%20");
 var cnt=0;

 if (items[index].Cells.results[21].Value ==null)
 {
 cnt =0;
 }
 else{
 cnt = items[index].Cells.results[21].Value;
 }
 totalcnt = totalcnt+parseInt(cnt);
 //$('#popular').append('<div class=recentitems><a target="_blank" class=itemtitle href='+itemlinks+'>'+items[index].Cells.results[3].Value+'</a> Hit counts are ' +cnt+'</div');
  $('#populardoc').append('<tr><td><a target="_blank" class=itemtitle href='+itemlinks+'>'+items[index].Cells.results[3].Value+'</a></td><td>' +cnt+'</td></tr>');
 });
  $('#populardoc').DataTable();
  $('#popularpadcapdoc-total').append('<div style="width:100%;"><h3 class="doctotal">'+totalcnt+'</h3><h3 class="doctotalcount">Total</h3></div>');

}
 });
 }
</Script>


Step3:

Before binding the data we  have to make sure that  table structure have formed  well with  <thead> tag and <tbody> tag. if u missed this structure it wont bind as excepted.

<table id="populardoc" class="table table-striped table-bordered">
<thead>
<tr>
<th>Document Name</th>
<th>No. of Hits</th>
</tr>
</thead>
<tbody>
</tbody>
</table>


Step4:

Final Output




Thanks for reading article.Stay Tune on www.webdesignersdairy.com  for more updates.

Validating to select in sequencial order using angular

    < input type = "checkbox" (change) = "handleSelectTaskItem($event, taskItem)" [checked] = " taskItem . i...