Archive

Archive for October, 2013

Allow Number Only In ASP.Net TextBox

October 30, 2013 Leave a comment

Hi all ,

try this example to allow number only in ASP.Net TextBox control according to user btowser

Javascript Code :


function CheckNumberOnly(e) {
 var unicode = e.keyCode ? e.keyCode : e.charCode;
 if (navigator.appName == 'Microsoft Internet Explorer') {
 if ((unicode == 9 /*TAB*/) || (unicode == 8/*BackSpace*/) || (unicode >= 48 && unicode <= 57) || (unicode == 96)) {
 return true;
 }
 else {
 return false;
 }
 }
 else {
 if ((event.keyCode >= 48 && event.keyCode <= 57) ||
 event.keyCode == 8/*BackSpace*/ || event.keyCode == 9 /*TAB*/ || event.keyCode == 37 ||
 event.keyCode == 39 || event.keyCode == 190) {
 return true;
 }
 else {
 return false;
 }
 }
}

In Code behind :

TextBox1.Attributes.Add("onkeypress", "return CheckNumberOnly(event)");

also you can check this post

Make TextBox accept Number only

Hope this helps

Good Luck

Advertisements
Categories: ASP.Net, Javascript

LogOut User to Login Page If there is no Activity

October 26, 2013 Leave a comment

Hi all,

try this example to LogOut User If there is no Activity


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
 <title>Timeout Test</title>
 <script type="text/javascript" src="jquery-1.9.1.js"></script>
 <script type="text/javascript" src="jquery-ui.min.js"></script>
 <link rel="stylesheet" href="jquery-ui.css" type="text/css" />
 <script>
 // Set timeout variables.
 var timoutWarning = 60000; // Display warning in 1 Min.
 var timoutNow = 120000; // Timeout in 2 Mins.
 var logoutUrl = 'Login.aspx'; // URL to logout page.
 var warningTimer;
 var timeoutTimer;
 // Start timers.
 function StartTimers() {
 warningTimer = setTimeout("IdleWarning()", timoutWarning);
 timeoutTimer = setTimeout("IdleTimeout()", timoutNow);
 }
 // Reset timers.
 function ResetTimers() {
 clearTimeout(warningTimer);
 clearTimeout(timeoutTimer);
 StartTimers();
 $("#timeout").dialog('close');
 }
 // Show idle timeout warning dialog.
 function IdleWarning() {
 $("#timeout").dialog({
 modal: true
 });
 }
 // Logout the user.
 function IdleTimeout() {
 window.location = logoutUrl;
 }
 </script>

<style>
 #timeout
 {
 display: none;
 }
 </style>
</head>
<body onload="StartTimers();" onmousemove="ResetTimers();">
 <form id="form1" runat="server">
 <h1>
 Do not move your mouse!</h1>
 <p>
 If you move your mouse over this window while it is selected it will reset the timer.</p>
 <div id="timeout">
 <h1>
 Session About To Timeout</h1>
 <p>
 You will be automatically logged out in 1 minute.<br />
 To remain logged in move your mouse over this window.
 </div>
 </form>
</body>
</html>

Hope this helps

Good Luck.

Categories: ASP.Net, Javascript, Jquery

Search stored procedures by names

October 20, 2013 Leave a comment

Hi all,

Try this example to Search Stored Procedures by Name using this SQL Query


SELECT *
FROM sys.procedures
WHERE name LIKE '%message%'

Hope this helps

Good Luck.

Categories: SQL Server

Creating a Custom View that filters on the Current User

October 18, 2013 Leave a comment

Hi all,

try this example to Create a Custom View that filters on the Current User in SharePoint 2010

I Create Custom List “Customers List” and i want to display Customers Created by Current User [Me]

filterviewbycurrentuser_thumb

Hope this helps

Good Luck.

 

Categories: SharePoint 2010

Show JQuery Dialog Window With Redirect from Code behind

October 17, 2013 Leave a comment

Hi all,

try this example to display JQuery Dialog Window with Redirect on close button from Code behind


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default10.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
 <title>JQuery Dialog With Redirect On Close</title>
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
 <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
 <link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/start/jquery-ui.css"
 rel="stylesheet" type="text/css" />
</head>
<body>
 <form id="form1" runat="server">
 <div id="alertdialog" style="display: none">
 </div>
 </form>
</body>
</html>

In code behind :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class _Default : System.Web.UI.Page
{
 private void ShowAlert(string message, string url)
 {
 ///Initialize the stringbuilder object to append JS script
 StringBuilder sb = new StringBuilder();
 sb.Append("$(function() { ");
 sb.Append("$('#alertdialog').empty();");
 sb.Append("$('#alertdialog').append('" + message + "');");
 sb.Append(" $('#alertdialog').dialog({");
 sb.Append(" width: 350,");
 sb.Append("buttons: {");
 sb.Append("'close': function(event, ui) { window.location.href = '" + url + "'; }");
 sb.Append(" }");
 sb.Append(" });");
 sb.Append("});");
 ///Register the script on page startup
 ClientScript.RegisterStartupScript(typeof(Page), "myscript", sb.ToString(), true);
 }

protected void Page_Load(object sender, EventArgs e)
 {
 ShowAlert("your message here", "page.htm");
 }
}

Hope this helps

Good Luck

 

Categories: ASP.Net, Javascript, Jquery

Display JQuery Popup Window from Server Side

October 16, 2013 Leave a comment

Hi all,

try this example to Display JQuery Popup Window from Server Side (Code behind)


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/start/jquery-ui.css"
 rel="stylesheet" type="text/css" />
<script type="text/javascript">
 function ShowPopup(message) {
 $(function () {
 $("#dialog").html(message);
 $("#dialog").dialog({
 title: "jQuery Popup Window",
 buttons: {
 Close: function () {
 $(this).dialog('close');
 }
 },
 modal: true
 });
 });
 };
</script>
<div id="dialog" style="display: none">
</div>
<asp:Button ID="btnShowPopup" runat="server" Text="Show Popup" OnClick="btnShowPopup_Click" />

In code behind :


protected void btnShowPopup_Click(object sender, EventArgs e)
{
 string message = "Message from server side";
 ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup('" + message + "');", true);
}

Hope this helps

Good Luck.

Categories: ASP.Net, Javascript, Jquery

How to Use HTML RadioButton Inside Gridview

October 5, 2013 Leave a comment

Hi all,

try this example to use HTML RadioButton inside Gridview row and get Selected value from Code behind


<asp:GridView ID="GridView1" runat="server"
 AutoGenerateColumns="False" BackColor="White"
 BorderColor="#CC9966" BorderStyle="None"
 BorderWidth="1px" CellPadding="4" Font-Names="Verdana">
 <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
 <Columns>
 <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" />
 <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" />
 <asp:BoundField DataField="Description" HeaderText="Description" />
 <asp:TemplateField HeaderText="Select One">
 <ItemTemplate>
 <input name="MyRadioButton" type="radio"
 value='<%# Eval("CategoryID") %>' />
 </ItemTemplate>
 </asp:TemplateField>
 </Columns>
 <RowStyle BackColor="White" ForeColor="#330099" />
 <SelectedRowStyle BackColor="#FFCC66"
 Font-Bold="True" ForeColor="#663399" />
 <PagerStyle BackColor="#FFFFCC"
 ForeColor="#330099" HorizontalAlign="Center" />
 <HeaderStyle BackColor="#990000"
 Font-Bold="True" ForeColor="#FFFFCC" />
</asp:GridView>

In code behind to get selected value


protected void Button1_Click(object sender, EventArgs e)
 {
 string selectedValue = Request.Form["MyRadioButton"];
 lblMsg.Text = selectedValue;
 }

Hope this helps

Good Luck.

Categories: ASP.Net