Asp.Net Textbox Numeric Only From Javascript

Write The folloeing Javascript

function NumericOnly()
{
var key = window.event.keyCode;
if((key < 46 || key > 57))//|| key != 46)
window.event.returnValue = false;
}

And Call  NumericOnly() javascript funvtion on  Key Press of TextBox

<asp:TextBox ID=”txtPhone” runat=”server” OnKeyPress=”NumericOnly()” MaxLength=”14″></asp:TextBox>

Sql server How to Use Comma Seperated Value in Subquery

–Declare Two Variable
–One For Comma Sepearated Value and the Other For Query
declare @test nvarchar(4000)
declare @values nvarchar (200)
–Tale your Comma seperated value i.e. 14,16,3,18 in @@values
set @values=(Select left(Empid,Len(EmpId)-1) as  EmployeeId  from TableName Where ColumnName=4)
–Add that @values in Test Which is nvarchar Qoery
set @test=’select * from Employee where EmployeeId in (‘+ (@values)+’)’
— Finally Execute that @test Query
EXEC(@test)

In Short

declare @test nvarchar(4000)
declare @values nvarchar (200)
set @values=(Select left(Empid,Len(EmpId)-1) as  EmployeeId  from TableName Where ColumnName=4)
set @test=’select * from Employee where EmployeeId in (‘+ (@values)+’)’
EXEC(@test)

How to Disable Back Button on Signout

To Disable Back Button of Browser on User Signout put this script in Signout button’s Page .

window.history.forward(1);

And if you need this functionality in Firefox also than add the following line .

-<META HTTP-EQUIV=”PRAGMA” CONTENT=”NO-CACHE”>-
-<META HTTP-EQUIV=”Expires” content=”-1″>-
-<META HTTP-EQUIV=”CACHE-CONTROL” CONTENT=”NO-STORE”>-

Server.Transfer v/s Response.Redirect

Server.Transfer v/s Response.Redirect

Response.Redirect involves a roundtrip to the server whereas  Server.Transfer conserves server resources by avoiding the roundtrip.
It just changes the focus of the webserver to a different page and  transfers the page processing to a different page.

Response.Redirect can be used for both .aspx and html pages whereas  Server.Transfer can be used only for .aspx pages
and is specific to ASP and ASP.NET.
With Response.Redirect you can redirect the user to the both type of pages .html or .aspx like below,Response.Redirect(“mypage.html”) OR Response.Redirect(“OtherPage.aspx”) But in case of Server.Transfer you can only work with .asp or .aspx page like below
Server.Transfer(“mypage.asp”) OR Server.Transfer(“OtherPage.aspx”)

Response.Redirect can be used to redirect a user to an external websites.  Server.Transfer can be used only on sites running on the same server.
You cannot use Server.Transfer to redirect the user to a page running on a different server.

Asp.Net Open Page as Modal Dialog — Parent Child Window Example

How to open Child Window From Parent Page and Close that Child window on Grid Editing and Use that Value  in Parent Page.

Put this Javascript on button’s  onClientSxript event

OnClientClick=”ViewAllHelp();”

function ViewAllHelp()

{    window.showModalDialog(‘frmViewEmployeeMaster.aspx’,’name’,’dialogHeight:417px; dialogWidth:800px; scroll:yes; status:no;location:no;’);
}

And in form ViewAll put this line in Html Tag

<base target=”_self”></base>

Now you can fill  Gridview for records and in Gridview Edit Operation you can close that modal Dialog  Form from the following Code

protected void dg_RowEditing(object sender, GridViewEditEventArgs e)
{
Label lblid = new Label();
lblid.Text = ((Label)dg.Rows[e.NewEditIndex].FindControl(“id”)).Text.ToString();
Session[“SearchId”]=lblid.Text.ToString();
ClientScript.RegisterClientScriptBlock(typeof(string), “closing”, “<script>window.close();</script>”);
}

And by using that session you can Use that value in Parent Page.