Sunday, June 1, 2014

How to remove the long space in the sentence using SQL SERVER

Step 1:- Example sentence

'Hello               Welcome   to   lokeshasp.blogspot.com'
Step2:-Write the below code
DECLARE @str varchar(150)

SET @str='Hello               Welcome   to   lokeshasp.blogspot.com'

Select REPLACE(REPLACE(REPLACE(@str,' ','[]'),'][',''),'[]',' ')
OutPut :-
Hello Welcome to lokeshasp.blogspot.com

Explanation
DECLARE @str varchar(150)

SET @str='Hello               Welcome   to   lokeshasp.blogspot.com'

Select REPLACE(@str,' ','{}')

O/P:-  Hello{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}Welcome{}{}{}to{}{}{}lokeshasp.blogspot.com
Select REPLACE(REPLACE(@str,' ','{}'),'}{','')

O/P:-   Hello{}Welcome{}to{}lokeshasp.blogspot.com
Select REPLACE(REPLACE(REPLACE(@str,' ','{}'),'}{',''),'{}',' ')

O/P:-   Hello Welcome to lokeshasp.blogspot.com

Full Code
DECLARE @str varchar(150)
SET @str='Hello               Welcome   to   lokeshasp.blogspot.com'
Select REPLACE(@str,' ','{}')
Select REPLACE(REPLACE(@str,' ','{}'),'}{','')
Select REPLACE(REPLACE(REPLACE(@str,' ','{}'),'}{',''),'{}',' ')


Read More »

Thursday, May 29, 2014

Working With __doPostBack Jquery Function In The Asp.Net C#

Introduction

In this article we are going to learn the topic of how to post back the dropdown selected change without changing the property of Autopostback=”true” .

For this we are going to call the method at the time of onchange event OnChange="dropDownChange();"

In this method we write the call back method with parameter condition like
__doPostBack('pnlGrid', strUser)

Coding

Write this code

In Aspx Source File

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">


Read More »

Get The Specific Column From The Data Table Using Asp.Net C#

Step 1:- Creating the dynamic data table

DataTable dt = new DataTable();
dt.Columns.Add("UserId", typeof(int));
dt.Columns.Add("UserName", typeof(string));
dt.Columns.Add("Education", typeof(string));
dt.Rows.Add(1, "Lokesh", "B.Tech");
dt.Rows.Add(2, "Vijay", "Msc");
dt.Rows.Add(3, "Balaji", "MS");
dt.Rows.Add(4, "Charan", "B.Tech");
dt.Rows.Add(5, "Durga", "MD");
dt.Rows.Add(6, "Shiva", "B.Tech");
dt.Rows.Add(7, "Venkat", "CA");

Step 2:- By using the “DefaultView”  Key word get the specific column from the existing the data table

DataTable dtDistinct = dt.DefaultView.ToTable(true, "UserName");

It will return only the "UserName” Column details


Read More »

Get the Specific Row From the Data Table using LINQ in Asp.Net

Step 1:- Create One dynamic datatable

DataTable dt = new DataTable();
dt.Columns.Add("UserId", typeof(int));
dt.Columns.Add("UserName", typeof(string));
dt.Columns.Add("Education", typeof(string));
dt.Rows.Add(1, "Lokesh", "B.Tech");
dt.Rows.Add(2, "Vijay", "Msc");
dt.Rows.Add(3, "Balaji", "MS");
dt.Rows.Add(4, "Charan", "B.Tech");
dt.Rows.Add(5, "Durga", "MD");
dt.Rows.Add(6, "Shiva", "B.Tech");
dt.Rows.Add(7, "Venkat", "CA");

This is the LINQ code for getting the specific row based on the Userid

var results = (from myRow in dt.AsEnumerable()
where myRow.Field<int>("UserId") == Convert.ToInt16(“1”)
                               select myRow).CopyToDataTable();

GridView1.DataSource = results;
GridView1.DataBind();


Read More »

Manipulating the Asp.Net Textbox with Custom Inputs using JQuery

Manipulating the Asp.Net Textbox with Custom Inputs using JQuery

Step 1:- Add this Source tag in the top
<script src="js/jquery-1.4.1.js" type="text/javascript"></script>

For jquery-1.4.1.js  this file follow below link

Step 2:- Write this code below

Put Client ID Mode Static in the Top ClientIDMode="Static" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TextBoxManipulationUsingJavascript.aspx.cs"
    Inherits="SampleTestingCodes.TextBoxManipulationUsingJavascript" ClientIDMode="Static" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="js/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#TextBox1').keyup(function (e) {
                var message = $("#TextBox1").val();
                var length = message.length;
                if (message.charAt(0) == "A") {
                    if (message.charAt(1) == "A") {
                        for (var i = 2; i < length; i++) {
                            if (message.charAt(i) >= 0 || message.charAt(i) <= 9) { }
                            else
                            { $("#TextBox1").val(message.slice(0, i)); }
                            if (length > 12)
                                $("#TextBox1").val(message.slice(0, 12));
                        }
                    }
                    else { $("#TextBox1").val(message.slice(0, 1)); }
                }
                else { $("#TextBox1").val(''); }
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>//////AA0123456789
    </div>
    </form>
</body>
</html>


Output:-

This Code textbox only allows

AA0123456789




For any clarifications or queries please don’t hesitate to call or Email 

Phone :- + 91-9492179390


Email :- lannam@technobrainltd.com (or) lokeshtec@gmail.com 



Read More »