Translate

Monday, 4 January 2016

Jquery Text Easy Counter



Jquery text easy Counter shown below




<h2>EasyCountrer</h2>
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Content/js/jquery.jqEasyCharCounter.min.js"></script>


<textarea id="easy" ></textarea>
<script>
    $(document).ready(function () {
        $("#easy").jqEasyCounter(
            {
                'maxChars': 160,
                        'maxCharsWarning': 150
            });
    });

</script>

OutPut:



Thursday, 17 December 2015

How to Bind Table Using Angular JS

Bind Table Using Angular JS

View:


<div ng-app="repeatTable" ng-controller="practiece1" id="App4">
        <table >
            <tr >
                <td>Id</td>
                <td>User Name</td>
                <td>First Name</td>
                 <td>Last Name</td>
                 <td>Location</td>
            </tr>
            <tr ng-repeat="data in tabledata" style="border: solid">
                <td>{{data.Id}}</td>
                <td>{{data.UserName}}</td>
                <td>{{data.FirstName}}</td>
                 <td>{{data.LastName}}</td>
                 <td>{{data.Location}}</td>
            </tr>
        </table>

    </div>

<script>
  var aps = angular.module('repeatTable', []).controller('practiece1', function ($scope, $http) {
            alert("");
            $http.get('/AngularJS/TableData').success(function (data) {
                alert(data);
                $scope.tabledata = data;
            });

        });
</script>


In Controller:

    public ActionResult TableData()
        {
            var text = context.UserInfoes.ToList();
            return Json(text,JsonRequestBehavior.AllowGet);
        }


Casacading Dropdowns using Angular JS

 Cascading Dropdown using Angular JS shown below

In view


@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
    <meta name="viewport" content="width=device-width" />
    <title>AngularJS1</title>
</head>

<div ng-app="myApp" ng-controller="MyCtrl">
    <select data-ng-model="country" data-ng-options="c.CountryId as c.CountryName for c in countries" data-ng-change="GetStates()">
        <option value="">-- Select Country --</option>
    </select>

    <select data-ng-model="state" data-ng-disabled="!states" data-ng-options="s.StateId as s.StateName for s in states">
        <option value="">-- Select State --</option>
    </select>
</div>
</html>
<script>
    var app = angular.module('myApp', []);
    app.controller('MyCtrl', function ($scope, $http) {
        $http({
            method: 'Get',
            url: '/AngularJS/GetCountries'
        }).success(function (data) {
            $scope.countries = data;
        }).error(function (data, status, headers, config) {
            $scope.message = 'Unexpected Error';
        });


        $scope.GetStates = function () {
          
            var countryId = $scope.country;
            alert(countryId);
            if (countryId) {
                $http({
                    method: 'POST',
                    url: '/AngularJS/GetStates/',
                    data: JSON.stringify({ countryId: countryId })
                }).success(function (data) {
                    $scope.states = data;
                }).error(function (data, status, headers, config) {
                    $scope.message = 'Unexpected Error';
                });
            }
            else {
                $scope.states = null;
            }
        }
    })
</script>



In Controller
public ActionResult AngularJS1()
        {
            return View();
        }


        public JsonResult GetCountries()
        {

                var ret = context.Countries.Select(x => new { x.CountryId, x.CountryName }).ToList();
                return Json(ret, JsonRequestBehavior.AllowGet);
        }

        [HttpPost]
        public JsonResult GetStates(int countryId)
        {
                var ret = context.States.Where(x => x.CountryId == countryId).Select(x => new { x.StateId, x.StateName }).ToList();
                return Json(ret);
        }


Wednesday, 9 December 2015

CRUD Operations in Classic ASP

Crud Operations In Classic ASP
First Open Visual Studio
 Goto File-New Web Site- Templates -Visual Basics - Asp.net Empty Website

Create website and add new item ->select html template- give name as List.asp


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <title></title>
    <script src="Scripts/jquery.fancybox-1.3.4.js"></script>
    <h1>Sample Classic Asp </h1>
    <%

dim db_connection

db_connection = "Provider=SQLOLEDB.1;Server=WEBDEL33\SQL2008R2;Database=Kavitha;Uid=sa; Pwd=Pwd4sql2008;"


set conn = server.createobject("adodb.connection")
set Cmd = Server.CreateObject("ADODB.Command")
'-------------------------------------------------------
conn.open (db_connection)
'-------------------------------------------------------
set rs = Server.CreateObject("ADODB.RecordSet")
    %>
    <%
sql="select * from Address"
set rs = Conn.execute(sql)

'if (rs.bof and rs.eof) then
       'response.Write "<span class=""error"">No Record Found</span>"
       'response.End
'end if
    %>
</head>
<body>
    <table border="1">
        <tr>
            <td>Edit</td>
            <td>Delete</td>
            <td>Name</td>
            <td>Mobile</td>
            <td>Email</td>
            <td>City</td>
        </tr>
        <%
             
              while not rs.eof
        %>
        <tr>

            <td><a href="add.asp?Name=<%=rs("Name")%>" class="news_frm"><%=rs("Name")%></a></td>
            <td><a href="Delete.asp?Id=<%=rs("Id")%>" class="news">Delete</a>
            </td>
            <td><%=rs("Name")%></td>
            <td><%=rs("Mobile")%></td>
            <td><%=rs("Email")%></td>
            <td><%=rs("City")%></td>

        </tr>

        <%
              rs.movenext
              wend
        %>
    </table>
    <div id="frmshow" style="display: none">
        <iframe src="/add.asp" width="400" height="400"></iframe>
    </div>


    <a href="add.asp">NewMember</a>



New Member/Update in add.asp:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
     <script type="text/javascript">
         function Submit_page() {
             if ($("#Name").val() == "") {
                 alert("Enter Name.");
                 return false;
             }
             if ($("#Text1").val() == "") {
                 alert("Enter Mobile.");
                 return false;
             }
             if ($("#Text2").val() == "") {
                 alert("Enter Email.");
                 return false;
             }
             if ($("#Text6").val() == "") {
                 alert("Enter Password.");
                 return false;
             }
             else
                 return true;
         }

        </script>
   

  

    <%

dim db_connection

db_connection = "Provider=SQLOLEDB.1;Server=WEBDEL33\SQL2008R2;Database=Kavitha;Uid=sa; Pwd=Pwd4sql2008;"


set conn = server.createobject("adodb.connection")
set Cmd = Server.CreateObject("ADODB.Command")
'-------------------------------------------------------
conn.open (db_connection)
'-------------------------------------------------------
set rs = Server.CreateObject("ADODB.RecordSet")
%>

<%
Name = request.QueryString("Name")
    if Name <> "" then
       sSQL = "SELECT top 1 * FROM Address where Name = '" & Name & "'"
       'response.Write sSQL
       set rs = Conn.execute(sSQL)
      
       if not(rs.bof and rs.eof) then
         Mobile = rs("Mobile")
              Email = rs("Email")
              Country =rs("Country")    
              State = rs("State")
              City = rs("City")
              Password = rs("Password")
        Address = rs("Address")
    Id=rs("Id")
       end if
end if

    %>
  
   
     </head>
<body>
   
    <form action="posting.asp" name="frm_config" id="frm_config" method="post">
    <table>
        <tr>
            <td>
                Name
            </td>
            <td>
                <% if Id <> "" then %><input type="hidden" name="Id" id="Id" value="<%=Id%>" /><% end if %>
           <input type="text" id="Name" name="Name"  value="<%=Name%>" /></td>
        </tr>
         <tr>
            <td>
                Mobile
            </td>
            <td><input type="text" id="Text1" name="Mobile" maxlength="10" value="<%=Mobile%>"/></td>
        </tr>
         <tr>
            <td>
                Email
            </td>
            <td><input type="text" id="Text2" name="Email" value="<%=Email%>"/></td>
        </tr>
         <tr>
            <td>
                Country
            </td>
            <td><input type="text" id="Text3" name="Country" value="<%=Country%>"/></td>
        </tr>
         <tr>
            <td>
                State
            </td>
            <td><input type="text" id="Text4" name="State" value="<%=State%>"/></td>
        </tr>
         <tr>
            <td>
               City
            </td>
            <td><input type="text" id="Text5" name="City" value="<%=City%>"/></td>
        </tr>
         <tr>
            <td>
                Password
            </td>
            <td><input type="text" id="Text6" name="Password" value="<%=Password%>"/></td>
        </tr>
         <tr>
            <td>
                Address
            </td>
            <td><input type="text" id="Text7" name="Address" value="<%=Address%>"/></td>
        </tr>
       
        <tr>
         
            <td>
                <input type="submit" id="btnsubmit" value="Submit" onclick="Submit_page()" /><div id="post_result"></div>
            </td>
            <td>
               
            </td>
        </tr>
    </table>
        </form>
  
</body>
  

</html>

Updating /Inserting in posting.asp:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <%

dim db_connection

db_connection = "Provider=SQLOLEDB.1;Server=WEBDEL33\SQL2008R2;Database=Kavitha;Uid=sa; Pwd=Pwd4sql2008;"


set conn = server.createobject("adodb.connection")
set Cmd = Server.CreateObject("ADODB.Command")
'-------------------------------------------------------
conn.open (db_connection)
'-------------------------------------------------------
set rs = Server.CreateObject("ADODB.RecordSet")
%>
    <%
Name = request.form("Name")
Mobile = request.form("Mobile")
Email= request.form("Email")
Address = request.form("Address")
Country = request.form("Country")
State= request.form("State")
City = request.form("City")
Password = request.form("Password")
  Id=request.Form("Id")

        if(Id>0) then
    
        sSQL="Update Address SET Mobile='" &Mobile& "',Email='" &Email& "', Country='" & Country & "',State='" & State & "',City='" & City & "',Password='" & Password & "',Address='" & Address& "'where Id='" & Id & "'"
       
        else
     sSQL= "INSERT INTO Address (Name,Mobile,Email,Address,Country,State,City,Password) values('" &(Name)& "','"&(Mobile) & "','"&(Email)&"','"&(Address)&"','"&(Country)&"','"&(State)&"','"&(City)&"','"&(Password)&"')"

end if
conn.execute(sSQL)
       response.Redirect("database.asp")
%>
</body>
   
</html>



Delete Member in Delete.asp:

     <%

dim db_connection

db_connection = "Provider=SQLOLEDB.1;Server=WEBDEL33\SQL2008R2;Database=Kavitha;Uid=sa; Pwd=Pwd4sql2008;"


set conn = server.createobject("adodb.connection")
set Cmd = Server.CreateObject("ADODB.Command")
'-------------------------------------------------------
conn.open (db_connection)
'-------------------------------------------------------
set rs = Server.CreateObject("ADODB.RecordSet")
%>
    <% 
        Id=request.QueryString("Id")
        if(Id>0) then
        sSQL="Exec sp_deleteaddress "&request.QueryString("Id")&""
     
        conn.execute(sSQL)
         response.Redirect("database.asp")
        end if
 %>
   <!--<script type="text/javascript">alert("Successful!");</script>-->