<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<style type="text/css">
.divNoBorder
{
background-color:White;
font-family:"Lucida Sans Unicode", "Lucida Grande", Verdana, Arial;
font-size:12px;
color:#000000;
width:510px;
margin-left:auto;
margin-right:auto;
padding:10px;
}
</style>
<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js"
type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var $divSlide = $("div.slide");
$divSlide.hide().eq(0).show();
var panelCnt = $divSlide.length;
setInterval(panelSlider, 3000);
function panelSlider() {
$divSlide.eq(($divSlide.length++) % panelCnt)
.slideUp("slow", function () {
$divSlide.eq(($divSlide.length) % panelCnt)
.slideDown("slow");
});
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="divNoBorder">
<h2>Slide Show with Panels.
Each Panel is Visible for 3 seconds.</h2>
<br /><br />
<asp:Panel ID="panelOne" runat="server" class='slide'>
Panel 1 Content Panel 1 Content Panel 1 Content
Panel 1 Content Panel 1 Content Panel 1 Content
Panel 1 Content Panel 1 Content Panel 1 Content
Panel 1 Content Panel 1 Content Panel 1 Content
</asp:Panel>
<asp:Panel ID="panelTwo" runat="server" class='slide'>
Panel 2 Content Panel 2 Content Panel 2 Content
Panel 2 Content Panel 2 Content Panel 2 Content
Panel 2 Content Panel 2 Content Panel 2 Content
Panel 2 Content Panel 2 Content Panel 2 Content
</asp:Panel>
<asp:Panel ID="panelThree" runat="server" class='slide'>
Panel 3 Content Panel 3 Content Panel 3 Content
Panel 3 Content Panel 3 Content Panel 3 Content
Panel 3 Content Panel 3 Content Panel 3 Content
Panel 3 Content Panel 3 Content Panel 3 Content
Panel 3 Content Panel 3 Content Panel 3 Content
</asp:Panel>
<asp:Panel ID="panelFour" runat="server" class='slide'>
Panel 4 Content Panel 4 Content Panel 4 Content
Panel 4 Content Panel 4 Content Panel 4 Content
</asp:Panel>
<asp:Panel ID="panelFive" runat="server" class='slide'>
Panel 5 Content Panel 5 Content Panel 5 Content
</asp:Panel>
</div>
</form>
</body>
</html>
Friday, September 24, 2010
Friday, September 17, 2010
Select only one check boxes and get that value on server side with the help of javascript [ using master pages ]
Javascript code:
<script language="javascript" type="text/javascript">
function checkBoxValidate(cb) {
var childs = document.getElementsByTagName('input');
for (var i = 0; i < childs.length; i++) {
if (childs[i].type == 'checkbox') {
if (childs[i].id != cb) {
childs[i].checked = false;
}
}
}
}
</script>
---------------------------------------------------------------------------------------------------
Define check boxes in the html side
<input type="checkbox" id="ckbox0" runat="server" checked="true" name="ckbox1" value="0" onclick="javascript:checkBoxValidate(this.id)" />
All
<input type="checkbox" id="ckbox1" runat="server" name="ckbox2" value="1" onclick="javascript:checkBoxValidate(this.id)" />
S<input type="checkbox" id="ckbox2" runat="server" name="ckbox3" value="2" onclick="javascript:checkBoxValidate(this.id)" />
M<input type="checkbox" id="ckbox3" runat="server" name="ckbox4" value="3" onclick="javascript:checkBoxValidate(this.id)" />
T<input type="checkbox" id="ckbox4" runat="server" name="ckbox5" value="4" onclick="javascript:checkBoxValidate(this.id)" />
W<input type="checkbox" id="ckbox5" runat="server" name="ckbox6" value="5" onclick="javascript:checkBoxValidate(this.id)" />
T<input type="checkbox" id="ckbox6" runat="server" name="ckbox7" value="6" onclick="javascript:checkBoxValidate(this.id)" />
F <input type="checkbox" id="ckbox7" runat="server" name="ckbox8" value="7" onclick="javascript:checkBoxValidate(this.id)" />
S
---------------------------------------------------------------------------------------------
Find check boxes in the server side in cs page in master pages
foreach (Control chk in this.Master.FindControl("ContentPlaceHolder1").Controls)
{
if (chk.GetType().ToString() == "System.Web.UI.HtmlControls.HtmlInputCheckBox")
{
HtmlInputCheckBox Chk1 = (HtmlInputCheckBox)chk;
if (Chk1.Checked)
{
Chk1.Checked = Chk1.Checked;
lbl.Text = Chk1.Value;
}
}
}
-------------------------its simple page---------------
foreach (Control chk in this.Page.FindControl("chhhh").Controls) //-- chhh div name
{
string a = chk.GetType().ToString();
if (chk.GetType().ToString() == "System.Web.UI.HtmlControls.HtmlInputCheckBox")
{
HtmlInputCheckBox Chk1 = (HtmlInputCheckBox)chk;
if (Chk1.Checked)
{
Chk1.Checked = Chk1.Checked;
}
}
}
_____________________________________________________________________
In this way we can find the html side check boxes value in server side using asp.net
<script language="javascript" type="text/javascript">
function checkBoxValidate(cb) {
var childs = document.getElementsByTagName('input');
for (var i = 0; i < childs.length; i++) {
if (childs[i].type == 'checkbox') {
if (childs[i].id != cb) {
childs[i].checked = false;
}
}
}
}
</script>
---------------------------------------------------------------------------------------------------
Define check boxes in the html side
<input type="checkbox" id="ckbox0" runat="server" checked="true" name="ckbox1" value="0" onclick="javascript:checkBoxValidate(this.id)" />
All
<input type="checkbox" id="ckbox1" runat="server" name="ckbox2" value="1" onclick="javascript:checkBoxValidate(this.id)" />
S<input type="checkbox" id="ckbox2" runat="server" name="ckbox3" value="2" onclick="javascript:checkBoxValidate(this.id)" />
M<input type="checkbox" id="ckbox3" runat="server" name="ckbox4" value="3" onclick="javascript:checkBoxValidate(this.id)" />
T<input type="checkbox" id="ckbox4" runat="server" name="ckbox5" value="4" onclick="javascript:checkBoxValidate(this.id)" />
W<input type="checkbox" id="ckbox5" runat="server" name="ckbox6" value="5" onclick="javascript:checkBoxValidate(this.id)" />
T<input type="checkbox" id="ckbox6" runat="server" name="ckbox7" value="6" onclick="javascript:checkBoxValidate(this.id)" />
F <input type="checkbox" id="ckbox7" runat="server" name="ckbox8" value="7" onclick="javascript:checkBoxValidate(this.id)" />
S
---------------------------------------------------------------------------------------------
Find check boxes in the server side in cs page in master pages
foreach (Control chk in this.Master.FindControl("ContentPlaceHolder1").Controls)
{
if (chk.GetType().ToString() == "System.Web.UI.HtmlControls.HtmlInputCheckBox")
{
HtmlInputCheckBox Chk1 = (HtmlInputCheckBox)chk;
if (Chk1.Checked)
{
Chk1.Checked = Chk1.Checked;
lbl.Text = Chk1.Value;
}
}
}
-------------------------its simple page---------------
foreach (Control chk in this.Page.FindControl("chhhh").Controls) //-- chhh div name
{
string a = chk.GetType().ToString();
if (chk.GetType().ToString() == "System.Web.UI.HtmlControls.HtmlInputCheckBox")
{
HtmlInputCheckBox Chk1 = (HtmlInputCheckBox)chk;
if (Chk1.Checked)
{
Chk1.Checked = Chk1.Checked;
}
}
}
_____________________________________________________________________
In this way we can find the html side check boxes value in server side using asp.net
Wednesday, September 15, 2010
NUMERIC Function in Transact-SQL.
In this article We will learn how to use numeric function in transact-SQL.
ABS(n) Function: Return the absolute values of the numeric expression n.
SYNTAX:
ABS(n)
n is the numeric expression and return the same type as numeric expression.
For example:
SYNTAX:
ACOS(n)
n is the float expression and return the same type as float expression.
For example:

ASIN(n)
n is the float expression and return the same type as float expression.
For example:

ABS(n) Function: Return the absolute values of the numeric expression n.
SYNTAX:
ABS(n)
n is the numeric expression and return the same type as numeric expression.
For example:
USE master
go
DECLARE @value float
SET @value = -45.34
SELECT 'The value of the ABS function is: ' + CONVERT(varchar,abs(@value))
GO
Output:
ACOS(n) Function: A mathematical function that calculate the arc cosine of n. n as well as the resulting value belonging to the FLOAT data type.
ACOS(n)
n is the float expression and return the same type as float expression.
For example:
USE master
go
DECLARE @cos float
SET @cos = -45.00
SELECT 'The ACOS of the number is: ' + CONVERT(varchar,abs(@cos))
GO
OUTPUT:
ASIN(n) Function: A mathematical function that calculate the arc sine of n. n as well as the resulting value belonging to the FLOAT data type.
SYNTAX:ASIN(n)
n is the float expression and return the same type as float expression.
For example:
USE master
go
DECLARE @angle float
SET @angle = 1.00
SELECT 'The ASIN of the angle is: ' + CONVERT(varchar,ASIN(@angle))
GO
OUTPUT:
CEILING(n): Ceiling return the smallest integer value greater or equal to the specified value n.
SYNTAX:
CEILING(n)
n is the numeric expression and return the same type as numeric expression.
For example:
USE master
go
select CEILING (24.78),CEILING (-24.78),CEILING (0.0)
go
OUTPUT:
getting number of days in the present month using sql
-- for getting number of days in the present month using sql ------------------------------------
SELECT DAY(DATEADD (m, 1, DATEADD (d, 1 - DAY(GETDATE()), GETDATE())) - 1) As NumDaysInMonth
SELECT DAY(DATEADD (m, 1, DATEADD (d, 1 - DAY(GETDATE()), GETDATE())) - 1) As NumDaysInMonth
How To Transfer Access database to SQL Server
http://www.dbtalks.com/UploadFile/brijesh_mcn/227/Default.aspx
Tuesday, September 14, 2010
How you can use csv file as data source of gridview
--- Image show the example of csv file-------------------------------
Here I will show how you can use csv file as data source of gridview.
Demo.csv file
firstname,lastname
hiren,soni
kirtan,patel
sanjay,parmar
ghanu,nayak
Output:
// get all lines of csv file
string[] str = File.ReadAllLines(Server.MapPath("demo.csv"));
// create new datatable
DataTable dt = new DataTable();
DataTable dt = new DataTable();
// get the column header means first line
string[] temp = str[0].Split(',');
string[] temp = str[0].Split(',');
// creates columns of gridview as per the header name
foreach(string t in temp)
{
dt.Columns.Add( t , typeof(string));
}
foreach(string t in temp)
{
dt.Columns.Add( t , typeof(string));
}
// now retrive the record from second line and add it to datatable
for(int i=1;i<str.Length;i++)
{
string[] t = str[i].Split(',');
dt.Rows.Add(t);
}
for(int i=1;i<str.Length;i++)
{
string[] t = str[i].Split(',');
dt.Rows.Add(t);
}
// assign gridview datasource property by datatable
GridView1.DataSource = dt;
GridView1.DataSource = dt;
// bind the gridview
GridView1.DataBind();
GridView1.DataBind();
Disable a submit button during Post Back In asp.net
--- Add these line on aspx page ---------------
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" Text="Submit" runat="server" onclick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel><br />
<asp:Button ID="Button2" Text="Save (without UpdatePanel)" runat="server" onclick="Button1_Click" />
<br /><br />
<asp:Button ID="Button3" Text="Save (with showing alert)" runat="server" onclick="Button1_Click" />
----------------------------------------------
---- Add thses live cs page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String sString = "this.style.backgroundColor='skyblue'; this.style.color='Red'; this.value='Saving Records... Please Wait...'; this.disabled = true; {0};";
String sHandler = String.Format(sString, this.ClientScript.GetPostBackEventReference(Button1,
String.Empty));
Button1.Attributes.Add("onclick", sHandler);
sHandler = "";
sHandler = String.Format(sString, this.ClientScript.GetPostBackEventReference(Button2,
String.Empty));
Button2.Attributes.Add("onclick", sHandler);
sHandler = "";
sHandler = String.Format(sString, this.ClientScript.GetPostBackEventReference(Button3,
String.Empty));
Button3.Attributes.Add("onclick", "javascript:alert('hello');" + sHandler);
}
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
}
}
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" Text="Submit" runat="server" onclick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel><br />
<asp:Button ID="Button2" Text="Save (without UpdatePanel)" runat="server" onclick="Button1_Click" />
<br /><br />
<asp:Button ID="Button3" Text="Save (with showing alert)" runat="server" onclick="Button1_Click" />
----------------------------------------------
---- Add thses live cs page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String sString = "this.style.backgroundColor='skyblue'; this.style.color='Red'; this.value='Saving Records... Please Wait...'; this.disabled = true; {0};";
String sHandler = String.Format(sString, this.ClientScript.GetPostBackEventReference(Button1,
String.Empty));
Button1.Attributes.Add("onclick", sHandler);
sHandler = "";
sHandler = String.Format(sString, this.ClientScript.GetPostBackEventReference(Button2,
String.Empty));
Button2.Attributes.Add("onclick", sHandler);
sHandler = "";
sHandler = String.Format(sString, this.ClientScript.GetPostBackEventReference(Button3,
String.Empty));
Button3.Attributes.Add("onclick", "javascript:alert('hello');" + sHandler);
}
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
}
}
http://www.c-sharpcorner.com/UploadFile/dougwagner/3185/
Interviews Tips
http://www.c-sharpcorner.com/UploadFile/dougwagner/3185/
http://www.c-sharpcorner.com/UploadFile/dougwagner/3185/
Tuesday, September 7, 2010
sorting the xml using xslt file in asp.net
function which used in c# file
private static XDocument SortUserInfo(XmlDocument UserInfo)
{
XmlDocument sortedXml = new XmlDocument();
XslCompiledTransform proc = new XslCompiledTransform();
proc.Load("C:\\Users\\graycell\\Desktop\\MultiHandleSliderExtender_w_Chart\\MultiHandleSliderExtender_w_Chart\\App_Data\\XSLTFile.xslt");
using (XmlWriter writer = sortedXml.CreateNavigator().AppendChild())
{
proc.Transform(UserInfo, writer);
}
string sorted = sortedXml.InnerXml;
return XDocument.Parse(sorted);
}
-------------------------------------------------------------------------------------------------
xml file-----
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="XSLTFile.xslt"?>
<CarsList>
<Car Date="01/01/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/02/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
<Car Date="01/03/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/04/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
<Car Date="01/05/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/06/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
<Car Date="01/07/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/08/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
<Car Date="01/09/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/10/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
<Car Date="01/11/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/12/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
<Car Date="01/13/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/14/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
<Car Date="01/15/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/16/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
</CarsList>
----------------------------------------------------------------------------------------------------
xslt file-----------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<CarsList>
<xsl:for-each select="CarsList/Car">
<xsl:sort select="current()/@CarBrand" order ="descending" />
<Car>
<xsl:attribute name="Date">
<xsl:value-of select="current()/@Date"/>
</xsl:attribute>
<xsl:attribute name="CarBrand">
<xsl:value-of select="current()/@CarBrand"/>
</xsl:attribute>
<xsl:attribute name="YearMonth">
<xsl:value-of select="current()/@YearMonth"/>
</xsl:attribute>
<xsl:attribute name="Count">
<xsl:value-of select="current()/@Count"/>
</xsl:attribute>
</Car>
</xsl:for-each>
</CarsList>
</xsl:template>
</xsl:stylesheet>
private static XDocument SortUserInfo(XmlDocument UserInfo)
{
XmlDocument sortedXml = new XmlDocument();
XslCompiledTransform proc = new XslCompiledTransform();
proc.Load("C:\\Users\\graycell\\Desktop\\MultiHandleSliderExtender_w_Chart\\MultiHandleSliderExtender_w_Chart\\App_Data\\XSLTFile.xslt");
using (XmlWriter writer = sortedXml.CreateNavigator().AppendChild())
{
proc.Transform(UserInfo, writer);
}
string sorted = sortedXml.InnerXml;
return XDocument.Parse(sorted);
}
-------------------------------------------------------------------------------------------------
xml file-----
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="XSLTFile.xslt"?>
<CarsList>
<Car Date="01/01/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/02/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
<Car Date="01/03/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/04/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
<Car Date="01/05/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/06/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
<Car Date="01/07/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/08/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
<Car Date="01/09/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/10/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
<Car Date="01/11/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/12/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
<Car Date="01/13/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/14/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
<Car Date="01/15/2005" YearMonth="200501" CarBrand="Audi" Count="15" />
<Car Date="01/16/2005" YearMonth="200501" CarBrand="Audi" Count="20" />
</CarsList>
----------------------------------------------------------------------------------------------------
xslt file-----------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<CarsList>
<xsl:for-each select="CarsList/Car">
<xsl:sort select="current()/@CarBrand" order ="descending" />
<Car>
<xsl:attribute name="Date">
<xsl:value-of select="current()/@Date"/>
</xsl:attribute>
<xsl:attribute name="CarBrand">
<xsl:value-of select="current()/@CarBrand"/>
</xsl:attribute>
<xsl:attribute name="YearMonth">
<xsl:value-of select="current()/@YearMonth"/>
</xsl:attribute>
<xsl:attribute name="Count">
<xsl:value-of select="current()/@Count"/>
</xsl:attribute>
</Car>
</xsl:for-each>
</CarsList>
</xsl:template>
</xsl:stylesheet>
Roting concept in asp,net 3.5 , 4.0
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
ShowHeader="False" onselectedindexchanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="select"
Text='<%# Eval("firstname") %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink runat="server" ID="lnkProduct1" NavigateUrl='<%# Page.GetRouteUrl("View Product", new { ProductName = Eval("Firstname").ToString() ,Name =Eval("Lastname").ToString()}) %>' Text='<%# Eval("Firstname") %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink runat="server" ID="lnkProduct2" NavigateUrl='<%# Page.GetRouteUrl("walia", new { walia = Eval("lastname").ToString() ,rakesh =Eval("firstname").ToString()}) %>' Text='<%# Eval("lastname") %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<p>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</p>
</form>
</body>
</html>
--------------------------------------------------------------------------------------------------
--- cs file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["cn"].ConnectionString;
SqlDataAdapter adp = new SqlDataAdapter("select * from tblemp", con);
if (con.State == ConnectionState.Closed)
{
con.Open();
}
DataSet ds = new DataSet();
adp.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string a="walia";
Response.Redirect (Page.GetRouteUrl ("View Product",new{ ProductName=a.ToString ()}));
//Page.GetRouteUrl("View Product", new { ProductName = "ProductName".ToString() });
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
-----------------------------------------------------------------------------------------
----global file
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
// Code that runs on application startup
}
void RegisterRoutes(RouteCollection routes)
{
// Register a route for Products/{ProductName}
routes.MapPageRoute(
"View Product", // Route name
"Indian Cricketer/{ProductName}/{Name}.go", // Route URL
"~/3d_Chart.aspx" // Web page to handle route
);
routes.MapPageRoute("walia", "john_cena/{walia}/{rakesh}.jsp", "~/Default4.aspx");
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
</script>
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
ShowHeader="False" onselectedindexchanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="select"
Text='<%# Eval("firstname") %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink runat="server" ID="lnkProduct1" NavigateUrl='<%# Page.GetRouteUrl("View Product", new { ProductName = Eval("Firstname").ToString() ,Name =Eval("Lastname").ToString()}) %>' Text='<%# Eval("Firstname") %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink runat="server" ID="lnkProduct2" NavigateUrl='<%# Page.GetRouteUrl("walia", new { walia = Eval("lastname").ToString() ,rakesh =Eval("firstname").ToString()}) %>' Text='<%# Eval("lastname") %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<p>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</p>
</form>
</body>
</html>
--------------------------------------------------------------------------------------------------
--- cs file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["cn"].ConnectionString;
SqlDataAdapter adp = new SqlDataAdapter("select * from tblemp", con);
if (con.State == ConnectionState.Closed)
{
con.Open();
}
DataSet ds = new DataSet();
adp.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string a="walia";
Response.Redirect (Page.GetRouteUrl ("View Product",new{ ProductName=a.ToString ()}));
//Page.GetRouteUrl("View Product", new { ProductName = "ProductName".ToString() });
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
-----------------------------------------------------------------------------------------
----global file
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
// Code that runs on application startup
}
void RegisterRoutes(RouteCollection routes)
{
// Register a route for Products/{ProductName}
routes.MapPageRoute(
"View Product", // Route name
"Indian Cricketer/{ProductName}/{Name}.go", // Route URL
"~/3d_Chart.aspx" // Web page to handle route
);
routes.MapPageRoute("walia", "john_cena/{walia}/{rakesh}.jsp", "~/Default4.aspx");
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
</script>
getting server value in javascript
<!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">
<script type="text/javascript" language="javascript" >
function abc() {
var servervalue = '<%:FromServer %>';
var vavv = '<%:vaaaa %>';
alert(servervalue);
alert(vavv);
}
</script>
</head>
<body onload="abc()">
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
---------------------------
cs code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
public string FromServer, vaaaa;
protected void Page_Load(object sender, EventArgs e)
{
FromServer = "Hi I am rakesh walia";
vaaaa = "sdfdsf fds sfdsfdsf dsfdsf dsfds";
}
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript" language="javascript" >
function abc() {
var servervalue = '<%:FromServer %>';
var vavv = '<%:vaaaa %>';
alert(servervalue);
alert(vavv);
}
</script>
</head>
<body onload="abc()">
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
---------------------------
cs code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
public string FromServer, vaaaa;
protected void Page_Load(object sender, EventArgs e)
{
FromServer = "Hi I am rakesh walia";
vaaaa = "sdfdsf fds sfdsfdsf dsfdsf dsfds";
}
}
stack bar chart in asp.net 3.4
-- html code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.DataVisualization.Charting" tagprefix="asp" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CHART id="Chart1" runat="server" Palette="BrightPastel"
BackColor="#EFE6F7" Width="688px" Height="440px" BorderDashStyle="Solid"
BackGradientStyle="TopBottom" BorderWidth="2" BorderColor="181, 64, 1"
onclick="Chart1_Click">
<titles>
<asp:Title ShadowColor="32, 0, 0, 0" Font="Trebuchet MS, 14.25pt, style=Bold" ShadowOffset="3" Text="Graycell Demo" Name="Title1" ForeColor="26, 59, 105"></asp:Title>
</titles>
<legends>
<asp:Legend TitleFont="Microsoft Sans Serif, 8pt, style=Bold" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style=Bold" IsTextAutoFit="False" Enabled="false" Name="Default"></asp:Legend>
</legends>
<borderskin SkinStyle="Emboss"></borderskin>
<series>
<asp:Series YValueType="String" XValueType="String" Name="FullName" IsValueShownAsLabel="true" IsVisibleInLegend="false" />
<%-- <asp:Series XValueType="Double" IsValueShownAsLabel="true" LegendText="Billable hours" ChartType="StackedColumn" Color="LightGreen"
Name="Billable" BorderColor="180, 26, 59, 105" CustomProperties="DrawingStyle=Cylinder" ShadowColor="DarkGreen">
</asp:Series>
<asp:Series XValueType="Double" IsValueShownAsLabel="true" Legend="non Billable hours" ChartType="StackedColumn" Color="LightCoral"
Name="nonBillable" BorderColor="180, 26, 59, 105" CustomProperties="DrawingStyle=Cylinder" ShadowColor="Transparent">
</asp:Series> --%>
</series>
<chartareas>
<asp:ChartArea Name="ChartArea1" BorderColor="64, 64, 64, 64" BackSecondaryColor="White" BackColor="#EFE6F7" ShadowColor="DarkRed" BackGradientStyle="TopBottom">
<area3dstyle Rotation="10" Perspective="10" Inclination="15" IsRightAngleAxes="False" WallWidth="0" IsClustered="False" />
<axisy LineColor="64, 64, 64, 64" LabelAutoFitMaxFontSize="8" Title="Hours">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
<MajorGrid LineColor="64, 64, 64, 64" />
</axisy>
<axisx LineColor="64, 64, 64, 64" LabelAutoFitMaxFontSize="8" Title="Members">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" IsEndLabelVisible="False" />
<MajorGrid LineColor="64, 64, 64, 64" />
</axisx>
</asp:ChartArea>
</chartareas>
</asp:CHART>
</div>
</form>
</body>
</html>
---------------------------------------------------------------------------------------------------------
C# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Xml.Linq;
using System.Collections;
using System.Drawing;
using System.Web.UI.DataVisualization.Charting;
using System.Globalization;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
foreach (Series series in this.Chart1.Series)
{
// this.Chart1.Series[2].PostBackValue = "#INDEX";
series.PostBackValue = "#INDEX";
}
Chart1.Series.Add("Billable");
Chart1.Series["Billable"].ChartType = SeriesChartType.StackedColumn;
Chart1.Series["Billable"].IsValueShownAsLabel = true;
this.Chart1.Series[1].PostBackValue = "#INDEX";
Chart1.Series.Add("nonBillable");
Chart1.Series["nonBillable"].ChartType = SeriesChartType.StackedColumn;
Chart1.Series["nonBillable"].IsValueShownAsLabel = true;
this.Chart1.Series[2].PostBackValue = "#INDEX";
Chart1.Series.Add("walia");
Chart1.Series["walia"].ChartType = SeriesChartType.StackedColumn;
Chart1.Series["walia"].IsValueShownAsLabel = true;
this.Chart1.Series[3].PostBackValue = "#INDEX";
Chart1.Series["Billable"].Points.AddY(37);
Chart1.Series["nonBillable"].Points.AddY(40);
Chart1.Series["walia"].Points.AddY(47);
Chart1.Series["Billable"].Points.AddY(13);
Chart1.Series["nonBillable"].Points.AddY(22);
Chart1.Series["walia"].Points.AddY(43);
Chart1.Series["Billable"].Points.AddY(11);
Chart1.Series["nonBillable"].Points.AddY(41);
Chart1.Series["Billable"].Points.AddY(1);
Chart1.Series["nonBillable"].Points.AddY(40);
Chart1.Series["Billable"].Points.AddY(10);
Chart1.Series["nonBillable"].Points.AddY(40);
Chart1.Series["Billable"].Points.AddY(16);
Chart1.Series["nonBillable"].Points.AddY(106);
Chart1.Series["Billable"].Points.AddY(16);
Chart1.Series["nonBillable"].Points.AddY(24);
Chart1.Series["Billable"].Points.AddY(21);
Chart1.Series["nonBillable"].Points.AddY(24);
Chart1.Series["Billable"].Points.AddY(21);
Chart1.Series["nonBillable"].Points.AddY(24);
//Chart1.Series["Billable"].Points.DataBindXY("CarBrand", "CarCount");
Chart1.Series["Billable"].Points[0].AxisLabel = "Tom";
Chart1.Series["Billable"].Points[1].AxisLabel = "Richard";
Chart1.Series["Billable"].Points[2].AxisLabel = "Harry";
Chart1.Series["Billable"].Points[3].AxisLabel = "walia";
Chart1.Series["Billable"].Points[4].AxisLabel = "sachin";
Chart1.Series["Billable"].Points[5].AxisLabel = "rahul";
Chart1.Series["Billable"].Points[6].AxisLabel = "gandhi";
Chart1.Series["Billable"].Points[7].AxisLabel = "cricket";
Chart1.Series["Billable"].Points[8].AxisLabel = "socker";
}
protected void Chart1_Click(object sender, ImageMapEventArgs e)
{
string a = e.PostBackValue;
Response.Write(a);
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.DataVisualization.Charting" tagprefix="asp" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CHART id="Chart1" runat="server" Palette="BrightPastel"
BackColor="#EFE6F7" Width="688px" Height="440px" BorderDashStyle="Solid"
BackGradientStyle="TopBottom" BorderWidth="2" BorderColor="181, 64, 1"
onclick="Chart1_Click">
<titles>
<asp:Title ShadowColor="32, 0, 0, 0" Font="Trebuchet MS, 14.25pt, style=Bold" ShadowOffset="3" Text="Graycell Demo" Name="Title1" ForeColor="26, 59, 105"></asp:Title>
</titles>
<legends>
<asp:Legend TitleFont="Microsoft Sans Serif, 8pt, style=Bold" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style=Bold" IsTextAutoFit="False" Enabled="false" Name="Default"></asp:Legend>
</legends>
<borderskin SkinStyle="Emboss"></borderskin>
<series>
<asp:Series YValueType="String" XValueType="String" Name="FullName" IsValueShownAsLabel="true" IsVisibleInLegend="false" />
<%-- <asp:Series XValueType="Double" IsValueShownAsLabel="true" LegendText="Billable hours" ChartType="StackedColumn" Color="LightGreen"
Name="Billable" BorderColor="180, 26, 59, 105" CustomProperties="DrawingStyle=Cylinder" ShadowColor="DarkGreen">
</asp:Series>
<asp:Series XValueType="Double" IsValueShownAsLabel="true" Legend="non Billable hours" ChartType="StackedColumn" Color="LightCoral"
Name="nonBillable" BorderColor="180, 26, 59, 105" CustomProperties="DrawingStyle=Cylinder" ShadowColor="Transparent">
</asp:Series> --%>
</series>
<chartareas>
<asp:ChartArea Name="ChartArea1" BorderColor="64, 64, 64, 64" BackSecondaryColor="White" BackColor="#EFE6F7" ShadowColor="DarkRed" BackGradientStyle="TopBottom">
<area3dstyle Rotation="10" Perspective="10" Inclination="15" IsRightAngleAxes="False" WallWidth="0" IsClustered="False" />
<axisy LineColor="64, 64, 64, 64" LabelAutoFitMaxFontSize="8" Title="Hours">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
<MajorGrid LineColor="64, 64, 64, 64" />
</axisy>
<axisx LineColor="64, 64, 64, 64" LabelAutoFitMaxFontSize="8" Title="Members">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" IsEndLabelVisible="False" />
<MajorGrid LineColor="64, 64, 64, 64" />
</axisx>
</asp:ChartArea>
</chartareas>
</asp:CHART>
</div>
</form>
</body>
</html>
---------------------------------------------------------------------------------------------------------
C# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Xml.Linq;
using System.Collections;
using System.Drawing;
using System.Web.UI.DataVisualization.Charting;
using System.Globalization;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
foreach (Series series in this.Chart1.Series)
{
// this.Chart1.Series[2].PostBackValue = "#INDEX";
series.PostBackValue = "#INDEX";
}
Chart1.Series.Add("Billable");
Chart1.Series["Billable"].ChartType = SeriesChartType.StackedColumn;
Chart1.Series["Billable"].IsValueShownAsLabel = true;
this.Chart1.Series[1].PostBackValue = "#INDEX";
Chart1.Series.Add("nonBillable");
Chart1.Series["nonBillable"].ChartType = SeriesChartType.StackedColumn;
Chart1.Series["nonBillable"].IsValueShownAsLabel = true;
this.Chart1.Series[2].PostBackValue = "#INDEX";
Chart1.Series.Add("walia");
Chart1.Series["walia"].ChartType = SeriesChartType.StackedColumn;
Chart1.Series["walia"].IsValueShownAsLabel = true;
this.Chart1.Series[3].PostBackValue = "#INDEX";
Chart1.Series["Billable"].Points.AddY(37);
Chart1.Series["nonBillable"].Points.AddY(40);
Chart1.Series["walia"].Points.AddY(47);
Chart1.Series["Billable"].Points.AddY(13);
Chart1.Series["nonBillable"].Points.AddY(22);
Chart1.Series["walia"].Points.AddY(43);
Chart1.Series["Billable"].Points.AddY(11);
Chart1.Series["nonBillable"].Points.AddY(41);
Chart1.Series["Billable"].Points.AddY(1);
Chart1.Series["nonBillable"].Points.AddY(40);
Chart1.Series["Billable"].Points.AddY(10);
Chart1.Series["nonBillable"].Points.AddY(40);
Chart1.Series["Billable"].Points.AddY(16);
Chart1.Series["nonBillable"].Points.AddY(106);
Chart1.Series["Billable"].Points.AddY(16);
Chart1.Series["nonBillable"].Points.AddY(24);
Chart1.Series["Billable"].Points.AddY(21);
Chart1.Series["nonBillable"].Points.AddY(24);
Chart1.Series["Billable"].Points.AddY(21);
Chart1.Series["nonBillable"].Points.AddY(24);
//Chart1.Series["Billable"].Points.DataBindXY("CarBrand", "CarCount");
Chart1.Series["Billable"].Points[0].AxisLabel = "Tom";
Chart1.Series["Billable"].Points[1].AxisLabel = "Richard";
Chart1.Series["Billable"].Points[2].AxisLabel = "Harry";
Chart1.Series["Billable"].Points[3].AxisLabel = "walia";
Chart1.Series["Billable"].Points[4].AxisLabel = "sachin";
Chart1.Series["Billable"].Points[5].AxisLabel = "rahul";
Chart1.Series["Billable"].Points[6].AxisLabel = "gandhi";
Chart1.Series["Billable"].Points[7].AxisLabel = "cricket";
Chart1.Series["Billable"].Points[8].AxisLabel = "socker";
}
protected void Chart1_Click(object sender, ImageMapEventArgs e)
{
string a = e.PostBackValue;
Response.Write(a);
}
}
getting comma separted value in sql [ using stuff function ]
---check table colum
select [name]
from employee
go
-- get csv comma seperated value ----
select stuff((select ',' + s.name from employee s order by s.name for xml path ('')),1,1,'') as csv
go
select [name]
from employee
go
-- get csv comma seperated value ----
select stuff((select ',' + s.name from employee s order by s.name for xml path ('')),1,1,'') as csv
go
Text box limit using javascript
here is the example of set the text box limit using javascript in asp.net
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Feedback Page</title>
<script language="JavaScript" type="text/javascript">
function CountText(field, maxlimit) {
if (field.disabled == false) {
if (field.value.length < maxlimit) // if too long...trim it!
{
return true;
}
else
return false;
}
}
function fnKeepWordLenTrack(keyevnt, field, maxlimit) {
var txtRemLen = document.getElementById("txtRemLen");
txtRemLen.value = maxlimit - field.value.length;
if (field.value.length > maxlimit)
field.value = field.value.substr(0, maxlimit);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
Please Enter Your Feedback in no more than 6000 alphabets<br />
<asp:TextBox ID="txtFeedback" runat="server" autocomplete="off" Height="198px"
MaxLength="6000" onblur="return fnKeepWordLenTrack(event,this,6000);"
onkeypress="return CountText(this,6000);"
onkeyup="return fnKeepWordLenTrack(event,this,6000);" TextMode="MultiLine"
Width="65%" BackColor="#D7EBFF"></asp:TextBox>
</div>
<p>
<input id="txtRemLen" maxlength="4" name="remLen" readonly="readonly" size="4"
style="width: 41px; height: 22px;" type="text" />
<asp:Label
ID="lblAlphabetsLeft" runat="server" Font-Size="10pt"
Text="alphabets left"></asp:Label>
</p>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Feedback Page</title>
<script language="JavaScript" type="text/javascript">
function CountText(field, maxlimit) {
if (field.disabled == false) {
if (field.value.length < maxlimit) // if too long...trim it!
{
return true;
}
else
return false;
}
}
function fnKeepWordLenTrack(keyevnt, field, maxlimit) {
var txtRemLen = document.getElementById("txtRemLen");
txtRemLen.value = maxlimit - field.value.length;
if (field.value.length > maxlimit)
field.value = field.value.substr(0, maxlimit);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
Please Enter Your Feedback in no more than 6000 alphabets<br />
<asp:TextBox ID="txtFeedback" runat="server" autocomplete="off" Height="198px"
MaxLength="6000" onblur="return fnKeepWordLenTrack(event,this,6000);"
onkeypress="return CountText(this,6000);"
onkeyup="return fnKeepWordLenTrack(event,this,6000);" TextMode="MultiLine"
Width="65%" BackColor="#D7EBFF"></asp:TextBox>
</div>
<p>
<input id="txtRemLen" maxlength="4" name="remLen" readonly="readonly" size="4"
style="width: 41px; height: 22px;" type="text" />
<asp:Label
ID="lblAlphabetsLeft" runat="server" Font-Size="10pt"
Text="alphabets left"></asp:Label>
</p>
</form>
</body>
</html>
Subscribe to:
Comments (Atom)
