
>Download Here
<asp:input>.. <html>.. <!DOCTYPE HTML... ..protected void Page_Load(object... <style type="text/css ... Select Error from Database...
Select @@MAX_Connections as MaxConn
Select @@Connections as TotalNumberOfLogin
Exec sp_monitor
<asp:BoundField DataField="DOB" HeaderText="DOB" DataFormatString = "{0:d}" />
<asp:BoundField DataField="DOB" HtmlEnclode="False" HeaderText="DOB" DataFormatString = "{0:d}" />
<ItemTemplate >
<asp:Label ID="DOB" runat="server" Text='<%# Bind("DOB") % >'> </asp:Label >
</ItemTemplate >
<asp:Label ID="DOB" runat="server" Text='<%# Bind("DOB","{0:D}") % >'> </asp:Label >
Format Pattern | Name | Example |
d | Short date | 11/8/2008 |
D | Long date | Sunday, August 11, 2008 |
t | Short time | 3:32 PM |
T | Long time | 3:32:00 PM |
f | Full date/time (short time) | Sunday, August 11, 2008 3:32 PM |
F | Full date/time (long time) | Sunday, August 11, 2008 3:32:00 PM |
g | General date/time (short time) | 8/11/2008 3:32 PM |
G | General date/time (long time) | 8/11/2008 3:32:00 PM |
m or M | Month day | August 11 |
r or R | RFC 1123 | Sun, 11 Aug 2008 8:32:00 GMT |
s | Sortable date/time | 2008-08-11T15:32:00 |
u | Universable sortable date/time | 2008-08-11 15:32:00z |
U | Universable sortable date/time | Sunday, August 11, 2008 11:32:00 PM |
y or Y | Year month | August, 2008 |
SELECT SERVERPROPERTY ('productlevel') ,SERVERPROPERTY('productversion'), SERVERPROPERTY ('edition')
Release | Sqlservr.exe |
RTM | 2007.100.1600.0 |
SQL Server 2008 Service Pack 1 | 2007.100.2531.0 |
C#
public bool GetIsConnAvail()
{
var success = false;
string StatusMsg;
if (NetworkInterface.GetIsNetworkAvailable() == false)
{
return success;
}
string[] Mysite = { "www.google.com", "www.yahoo.com"};
try
{
using (var ping = new Ping())
{
foreach (var url in Mysite)
{
var replyMsg = ping.Send(url, 300);
if (replyMsg.Status == IPStatus.Success)
{
success = true;
StatusMsg = "Connection Found..."
break;
}
else
{
StatusMsg = "Internet Connection not Found on your machine..."
}
}
}
}
catch (Exception ex)
{
Trace.WriteLine(ex.Message);
}
return success;
}
< %
Const adOpenStatic = 3
Const adLockPessimistic = 2
Dim cnnExcel
Dim rstExcel
Dim I
Dim iCols
Set cnnExcel = Server.CreateObject("ADODB.Connection")
cnnExcel.Open "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq="&Server.MapPath("1.xls")&";DefaultDir="&Server.MapPath(".")&";" Set rstExcel = Server.CreateObject("ADODB.Recordset")
rstExcel.Open "SELECT * FROM [Sheet1$]", cnnExcel
iCols = rstExcel.Fields.Count
rstExcel.MoveFirst
xmlData = ""
xmlData = xmlData&""
Do While Not rstExcel.EOF
xmlData = xmlData& ""
xmlData = xmlData& ""& rstExcel.Fields.Item(0).Value & " " & vbCrLf
xmlData = xmlData& " "
rstExcel.MoveNext
Loop
xmlData = xmlData& " "
Response.Write(xmlData)
rstExcel.Close
Set rstExcel = Nothing
cnnExcel.Close
Set cnnExcel = Nothing
% >
if(Page_IsValid)
{
//write your code here.
}
function DisableClick() {
var obj = 'btnUpd';
if (Page_IsValid) {
document.getElementById(obj).disabled = true;
txt = txt + 1;
message = 'Please Wait......(' + txt + ')!';
document.getElementById(obj).value = message;
var t = setTimeout('DisableClick()', 600);
}
else
{
document.getElementById(obj).disabled = false;
document.getElementById('PleaseWait').style.display = 'none';
document.getElementById(obj).value = "Register";
}
}
<cc1:CaptchaControl ID="ccJoin" runat="server" CaptchaBackgroundNoise="none" CaptchaLength="5" CaptchaHeight="60" CaptchaWidth="200" CaptchaLineNoise="None" CaptchaMinTimeout="5" CaptchaMaxTimeout="240" / >
ccJoin.ValidateCaptcha(txtCap.Text);
if (!ccJoin.UserValidated)
{
//Inform user that his input was wrong ...
return;
}
Drop Cap – Capital Letters with CSS
How to Create a Block Hover Effect for a List of Links
CSS Image Replacement for Buttons
10.
CSS Unordered List Calender
14.
Printing Web-Documents and CSS
public void ConvCSVToXML()
{
String[] FileContent = File.ReadAllLines(@"D:\Proj\jquery.csv");
String XMLNS = "";
XElement Inv = new XElement("type", from
items in FileContent
let fields = items.Split(',')
select new XElement("fadein",
new XElement("Tab", fields[0]),
new XElement("ProgressBar", fields[1]),
new XElement("ToolTip", fields[2]),
new XElement("Menu", fields[3]),
)
);
File.WriteAllText(@"D:\Proj\jquery.xml", XMLNS + Inv.ToString() );
}
For i = MyArray.GetLowerBound(0) To MyArray.GetUpperBound(0)
Next i
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
string remoteUri = "http://www.entersitenamehere.com";
WebClient client = new WebClient();
string str = client.DownloadString(remoteUri);
declare @Str VARCHAR(2000)
SET @Str = 'Hi this is Test line which count no of spaces.'
select LEN(@Str) - LEN(Replace(@Str,' ', '')) + 1
CREATE FUNCTION [dbo].[WordCount] ( @inStr VARCHAR(4000) )
RETURNS INT
AS
BEGIN
DECLARE @Index INT
DECLARE @Char CHAR(1)
DECLARE @PrevChar CHAR(1)
DECLARE @WordCount INT
SET @Index = 1
SET @WordCount = 0
WHILE @Index <= LEN(@InStr)
BEGIN
SET @Char = SUBSTRING(@InStr, @Index, 1)
SET @PrevChar = CASE WHEN @Index = 1 THEN ' '
ELSE SUBSTRING(@InStr, @Index - 1, 1)
END
IF @PrevChar = ' ' AND @Char != ' '
SET @WordCount = @WordCount + 1
SET @Index = @Index + 1
END
RETURN @WordCount
END
GO
DECLARE @String VARCHAR(4000)
SET @String = 'Hi this is Test line which count no of spaces.'
SELECT [dbo].[WordCount] ( @String )
select [ipadd] as IpAddress from ip order by [ipadd]
ipAddress
------------------------
10.0.0.1
192.165.20.2
255.205.2.3
255.145.53.6
64.35.88.9
68.4.5.99
69.65.236.235
98.125.85.36.0
ipAddress
------------------------
10.0.0.1
64.35.88.9
68.4.5.99
69.65.236.235
98.125.85.36.0
192.165.20.2
255.205.2.3
255.145.53.6
select [IPAdd] from ip
order by CAST(PARSENAME([IPAdd], 4) AS INT),
CAST(PARSENAME([IPAdd], 3) AS INT),
CAST(PARSENAME([IPAdd], 2) AS INT),
CAST(PARSENAME([IPAdd], 1) AS INT),
String strDtd = "";
XmlPreloadedResolver resolver = new XmlPreloadedResolver();
resolver.Add(resolver.ResolveUri(null, "nameofDTD.dtd"), strDtd);
XmlReaderSettings rs = new XmlReaderSettings();
rs.XmlResolver = resolver;
rs.DtdProcessing = DtdProcessing.Parse;
XmlReader reader = XmlReader.Create("samplexml.xml", rs);
XmlReaderSettings settings = new XmlReaderSettings();
//define the Setting object to parsing DTD
settings.DtdProcessing = DtdProcessing.Parse;
// Define preloading Xhtml10 DTD
settings.XmlResolver = new XmlPreloadedResolver(XmlKnownDtds.Xhtml10);
//suppose read the sample.html file using XmlReader
XmlReader reader = XmlReader.Create("sample.html", settings);
// and load using XDocument object
XDocument document = XDocument.Load(reader);
function gvHigh(tRow,showAct)
{
if (showAct)
{
tRow.style.backgroundColor = '#ff32ss';
}
else
{
tRow.style.backgroundColor = '#ffffff';
}
}
function urlloca(Url)
{
document.location.href = Url;
}
protected void gv1_onRowCreated(object sender, EventArgs e)
{
foreach (GridViewRow gvRow in gv1.Rows)
{
gvRow.Attributes["onmouseover"] = "highlight(this, true);";
gvRow.Attributes["onmouseout"] = "highlight(this, false);";
HttpResponse myHttpResponse = Response;
HtmlTextWriter myHtmlTextWriter = new HtmlTextWriter(myHttpResponse.Output);
gvRow.Attributes.AddAttributes(myHtmlTextWriter);
}
}
<head id="Head_Demo" runat="server">
<asp:ContentPlaceHolder runat="server" id="Contentplace_Demo"> </asp:ContentPlaceHolder>
</head >
function mXbar(action) {
if (action.pageX) return action.pageX;
else if (action.clientX)
return action.clientX + (document.documentElement.scrollLeft ?document.documentElement.scrollLeft :document.body.scrollLeft);
else return null;
}
function mYbar(action) {
if (action.pageY) return action.pageY;
else if (action.clientY)
return action.clientY + (document.documentElement.scrollTop ?document.documentElement.scrollTop :document.body.scrollTop);
else return null;
}
Public LinkButton linkFromMasterPage(){
Get {
Return linkFromMasterPage;
}
}
CusMasterPg cm = ((CusMasterPg) (Master));
protected void Page_Load(object sender, EventArgs e)
{
If (!(IsNothing(cm))) {
cm.linkFromMasterPage.Click += New EventHandler(linkFromMasterPage_Click);
}
}
Protected void linkFromMasterPage_Click(Object sender, System.EventArgs e){
// write Perform Business Logic Here
}
<%dim TodayDnT
TodayDnT = now()
%>
<%
Response.write FormatDateTime(TodayDnT,0)
%>
<%
Response.write FormatDateTime(TodayDnT,1)
%>
<%
Response.write FormatDateTime(TodayDnT,2)
%>
<%
Response.write FormatDateTime(TodayDnT,3)
%>
<%
Response.write FormatDateTime(TodayDnT,4)
%>
<configuration>
<system.web>
<compilation defaultLanguage="VB" debug="true" numRecompilesBeforeAppRestart="15">
<compilers>
<compiler language="C#;Csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,system, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
<compiler language="VB;VBScript" extension=".cls" type="Microsoft.VisualBasic.VBCodeProvider,system, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
</compilers>
<assemblies>
<add assembly="ADODB" />
<add assembly="*" />
</assemblies>
<namespaces>
<add namespace="System.Web.UI" />
<add namespace="System.Web" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
</compilation>
</system.web>
</configuration>
<%
dim i
For Each i in Session.Contents
Response.Write(i & "<br />")
Next
dim i
For Each i in Session.StaticObjects
Response.Write(i & "<br />")
Next
%>
<%
dim i
For Each i in Application.Contents
Response.Write(i & "<br />")
Next
%>
<%
for each x in Request.form
Response.Write("<br>" & x & " = " & Request.form(x))
next
%>
<%
for each name in Request.ServerVariables
Response.write ""&name &"-------------"& Request.ServerVariables(name) &"<br>"
Next
%>
<script language="javascript">
function toggle() {
var ele = document.getElementById("togText");
var text = document.getElementById("ShowText");
if(ele.style.display == "block") {
ele.style.display = "none";
text.innerHTML = "Click Me";
}
else {
ele.style.display = "block";
text.innerHTML = "Hide It";
}
}
</script>
Click Here to View Details
<a id="ShowText" href="javascript:toggle();">
Click Me </a>
<div id="togText" style="display: none">
< h1 > Hi, Kiran hows you? Hope u like this Cool stuff. < /h1 >
</div>
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="shortcut icon" href="images/favicon.ico" type="image/vnd.microsoft.icon" *gt;
DataTable dtsource = new DataTable();
//Adding columns to datatable
dtsource.Columns.Add("Person");
dtsource.Columns.Add("Related Blog");
//Adding records to the datatable
dtsource.Rows.Add("kiran", "kirank.blog.com");
dtsource.Rows.Add("kiran", "webdevlopmenthelp");
dtsource.Rows.Add("kiran", "www.kiran.com");
dtsource.Rows.Add("mark", "mark.blog.com");
dtsource.Rows.Add("mark", "asp-net.blogspot.com");
private void GenerateUniqueData(int cellno)
{
//Logic for unique names
//Step 1:
string initialnamevalue = grdUniqueNames.Rows[0].Cells[cellno].Text;
//Step 2:
for (int i = 1; i < grdUniqueNames.Rows.Count; i++)
{
if (grdUniqueNames.Rows[i].Cells[cellno].Text == initialnamevalue)
grdUniqueNames.Rows[i].Cells[cellno].Text = string.Empty;
else
initialnamevalue = grdUniqueNames.Rows[i].Cells[cellno].Text;
}
}
<script runat="server">
private int _Departmentid=0;
public int DepartMentId
{
get{return _Departmentid;}
set{_Departmentid =value;}
}
//Load event of control
void Page_Load(Object sender, EventArgs e)
{
lblText.Text = "Time is " + DateTime.Now.ToString() + " for Department id = "
+ _Departmentid + "\n";
}
</script>
<asp:Label id="lblText" runat="server"></asp:Label>
<%@ Page Language="C#" Trace="true" %>
<%@ Register TagPrefix="CacheSample" TagName="Text" Src="CachingControl.ascx" %>
<script runat=server>
void Page_Load(Object sender, EventArgs e)
{
this.lbltime.Text ="Base form time is " + DateTime.Now.ToString() + "\n";
}
</script>
<html><head><title></title><body>
<asp:Label id="lbltime" runat="server"></asp:Label>
<CACHESAMPLE:TEXT id="instance1" runat="Server" DepartMentId="0">
</CACHESAMPLE:TEXT>
<CACHESAMPLE:TEXT id="instance2" runat="Server" DepartMentId="1">
</CACHESAMPLE:TEXT>
</body>
</html>
- Application Level Caching
With Page level Output caching one cannot cache objects between pages within an application. Fragment caching is great in that sense but has limitations by using user controls as means to do. We can use the Cache object programmatically to take advantage of caching objects and share the same between pages. Further the availability of different overloaded methods gives a greater flexibility for our Cache policy like Timespan, Absolute expiration etc. But one of the biggest takes is the CacheDependancy. This means that one can create a cache and associate with it a dependency that is either another cache key or a file.
Find below the snippet that uses CacheDependancy. Here what I have done is to provide a list view of existing employees. You need to create a Database in Sql Server, setup some data before you can continue. The schema scripts are enclosed in the article.
Add database connection value in Web.Config and change the value as per your setup.
<appSettings>
<add key="conn" value="Data Source=vishnu;trusted_connection=yes;Initial Catalog=Users"/>
</appSettings>
First I get the dataset into which I fill the user list. But before this I check for the cache initially if it exists I directly cast it to a dataset, if not create a cache again.
daUsers.Fill(dsUsers,"tblUsers");
- Page Level Output Caching
This is at the page level and one of the easiest means for caching pages. This requires one to specify Duration of cache and Attribute of caching.
private void Page_Load()
{
if (!IsPostBack)
{
// Validate initially to force asterisks
// to appear before the first roundtrip.
Validate();
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
PageDataBind();
}
else
{
Response.write("2nd Time Visisted..");
}
}
protected void PageDataBind(string SearchProduct)
{
SqlDataAdapter SDA ;
DataSet ds = new DataSet();
String sql = "select * from Emp where ID ='"+ DropDownList.SelectedItem.Text +"'";
SDA.Fill(ds, "productDetails");
ShowId.DataSource = ds;
ShowId.DataBind();
}
<asp:TemplateField HeaderText="Header 3">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text="Click Me"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
protected void Gridview1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label l = (Label)e.Row.FindControl("Label1");
if (l != null)
{
string script = "window.open('Default.aspx');";
l.Attributes.Add("onclick", script);
}
}
}
opencontactsnet OpenContact.NET 1.0 file released: OpenContactsNet-1.0.zip
<script type="text/javascript" src="CountDown.js"> <script>
<script type="text/javascript">
window.onload=WindowLoad;
function WindowLoad(event) {
ActivateCountDown("CountDownPanel", 100);
}
</script>
var _countDowncontainer=0;
var _currentSeconds=0;
function ActivateCountDown(strContainerID, initialValue) {
_countDowncontainer = document.getElementById(strContainerID);
if (!_countDowncontainer) {
alert("count down error: container does not exist: "+strContainerID+
"\nmake sure html element with this ID exists");
return;
}
SetCountdownText(initialValue);
window.setTimeout("CountDownTick()", 1000);
}
function CountDownTick() {
if (_currentSeconds <= 0) {
alert("your time has expired!");
return;
}
SetCountdownText(_currentSeconds-1);
window.setTimeout("CountDownTick()", 1000);
}
function SetCountdownText(seconds) {
//store:
_currentSeconds = seconds;
//get minutes:
var minutes=parseInt(seconds/60);
//shrink:
seconds = (seconds%60);
//get hours:
var hours=parseInt(minutes/60);
//shrink:
minutes = (minutes%60);
//build text:
var strText = AddZero(hours) + ":" + AddZero(minutes) + ":" + AddZero(seconds);
//apply:
_countDowncontainer.innerHTML = strText;
}
function AddZero(num) {
return ((num >= 0)&&(num < 10))?"0"+num:num+"";
}
[OperationContract]
public void SubmitUserStatus(string username, string tweet)
{
// encode the username/password
string user = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));
// determine what we want to upload as a status
byte[] bytes = System.Text.Encoding.ASCII.GetBytes("status=" + tweet);
// connect with the update page
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://twitter.com/statuses/update.xml");
// set the method to POST
request.Method = "POST";
// thanks to argodev for this recent change!
request.ServicePoint.Expect100Continue = false;
// set the authorisation levels
request.Headers.Add("Authorization", "Basic " + user);
request.ContentType = "application/x-www-form-urlencoded";
// set the length of the content
request.ContentLength = bytes.Length;
// set up the stream
Stream reqStream = request.GetRequestStream();
// write to the stream
reqStream.Write(bytes, 0, bytes.Length);
// close the stream
reqStream.Close();
}
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MSXML2;
public partial class MSXML : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
// to get page data (using msxml4)
XMLHTTP40 http = new XMLHTTP40();
http.open("GET", "http://www.xyz.xom/sendResult.aspx"+TextBox1.Text+"", false, null, null);
http.send();
string value = http.responseText;
Response.Write(value.ToString());
}
}
<form id="form2" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
</form>
<asp:SqlDataSource id="datasource1" runat="server" SelectCommand="SELECT CustomerID, CompanyName, City FROM Customers"
/>
<asp:GridView id="gridview1" DataSourceID="datasource1" runat="server"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="CustomerID" HeaderText="BoundField" />
<asp:HyperLinkField
DataTextField="CustomerName"
DataNavigateUrlFields="CustomerID,City"
DataNavigateUrlFormatString=
"http://xyz.com/ShowUser.aspx?id={0}&city={1}" />
</Columns>
</asp:GridView>
if (Context.Request.ServerVariables["HTTP_VIA"] != null)
{
IP = Context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else
{
IP = Context.Request.ServerVariables["REMOTE_ADDR"].ToString();
}
<asp:DataList ID="dlCountry" runat="server">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Country_Code") %>'></asp:Label>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Country_Name") %>'></asp:Label>
</ItemTemplate>
</asp:DataList>
<asp:DataList ID=" dlPaging" runat="server" OnItemCommand="dlPaging _ItemCommand">
<ItemTemplate>
<asp:LinkButton ID="lnkbtnPaging" runat="server" CommandArgument='<%# Eval("PageIndex") %>' CommandName="lnkbtnPaging" Text='<%# Eval("PageText") %>'></asp:LinkButton>
</ItemTemplate>
</asp:DataList>
private void BindGrid()
{
string sql = "Select * from Country Order By Country_Name";
SqlDataAdapter da = new SqlDataAdapter(sql, “Yourconnectionstring”);
DataTable dt = new DataTable();
da.Fill(dt);
pds.DataSource = dt.DefaultView;
pds.AllowPaging = true;
pds.PageSize = Convert.ToInt16(ddlPageSize.SelectedValue);
pds.CurrentPageIndex = CurrentPage;
lnkbtnNext.Enabled = !pds.IsLastPage;
lnkbtnPrevious.Enabled = !pds.IsFirstPage;
dlCountry.DataSource = pds;
dlCountry.DataBind();
doPaging();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
public int CurrentPage
{
get
{
if (this.ViewState["CurrentPage"] == null)
return 0;
else
return Convert.ToInt16(this.ViewState["CurrentPage"].ToString());
}
set
{
this.ViewState["CurrentPage"] = value;
}
}
private void doPaging()
{
DataTable dt = new DataTable();
dt.Columns.Add("PageIndex");
dt.Columns.Add("PageText");
for (int i = 0; i < pds.PageCount; i++)
{
DataRow dr = dt.NewRow();
dr[0] = i;
dr[1] = i + 1;
dt.Rows.Add(dr);
}
dlPaging.DataSource = dt;
dlPaging.DataBind();
}
protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName.Equals("lnkbtnPaging"))
{
CurrentPage = Convert.ToInt16(e.CommandArgument.ToString());
BindGrid();
}
}
protected void lnkbtnPrevious_Click(object sender, EventArgs e)
{
CurrentPage -= 1;
BindGrid();
}
protected void lnkbtnNext_Click(object sender, EventArgs e)
{
CurrentPage += 1;
BindGrid();
}
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
CurrentPage = 0;
BindGrid();
}
protected void dlPaging_ItemDataBound(object sender, DataListItemEventArgs e)
{
LinkButton lnkbtnPage = (LinkButton)e.Item.FindControl("lnkbtnPaging");
if (lnkbtnPage.CommandArgument.ToString() == CurrentPage.ToString())
{
lnkbtnPage.Enabled = false;
lnkbtnPage.Font.Bold = true;
}
}