Java script is languages that gives functionality in html.
Tuesday, December 25, 2012
Tuesday, November 20, 2012
Find from tag of xml
string strValue = "";
strValue = "<search(key)>123<search(key)>";
//for value
string from=strValue.Remove( strValue.LastIndexOf('<'));
string value = from.Substring(from.LastIndexOf('>')+1);
//for parametr
string parametefrom = strValue.Substring(strValue.LastIndexOf('(')+1);
string parameter = parametefrom.Remove(parametefrom.LastIndexOf(')'));
strValue = "<search(key)>123<search(key)>";
//for value
string from=strValue.Remove( strValue.LastIndexOf('<'));
string value = from.Substring(from.LastIndexOf('>')+1);
//for parametr
string parametefrom = strValue.Substring(strValue.LastIndexOf('(')+1);
string parameter = parametefrom.Remove(parametefrom.LastIndexOf(')'));
Thursday, August 30, 2012
Simple Web Crawler in C# to get Html content
WebRequest request = WebRequest.Create("http://google.com/");//Type url here
using (WebResponse response = request.GetResponse())
{
using (StreamReader responseReader =
new StreamReader(response.GetResponseStream()))
{
string responseData = responseReader.ReadToEnd();
string path= Server.MapPath(".");
if(!File.Exists(path+"//Asptrick.html"))
File.Create(path+"//Asptrick.html");
using (StreamWriter writer =
new StreamWriter(path + "//Asptrick.html")) //Where You Want to save Content
{
writer.Write(responseData);
}
}
}
use namespace for this as following:
using System.IO;
using System.Net;
using (WebResponse response = request.GetResponse())
{
using (StreamReader responseReader =
new StreamReader(response.GetResponseStream()))
{
string responseData = responseReader.ReadToEnd();
string path= Server.MapPath(".");
if(!File.Exists(path+"//Asptrick.html"))
File.Create(path+"//Asptrick.html");
using (StreamWriter writer =
new StreamWriter(path + "//Asptrick.html")) //Where You Want to save Content
{
writer.Write(responseData);
}
}
}
use namespace for this as following:
using System.IO;
using System.Net;
Friday, May 4, 2012
Saturday, April 21, 2012
Create Table Dynamically from Data table When Column of Data Table conver to Table Cell or row.
Supoose We Have Table Employee
DataTable dt1;
DataTable dt2;
Table tb = new Table();
tb.CssClass = "mGrid";
Int32 k = 1;
string lastvalue = "";
for (int i = 0; i < dt.Rows.Count; i++)
{
String empNo = dt1.Rows[i][0].ToString();
TableRow tbrow = new TableRow();
TableRow tbr = new TableRow();
TableRow tbr1 = new TableRow();
if (i == 0)
{
TableHeaderCell tbHcell = new TableHeaderCell();//Header Row for Serial No
tbHcell.Width = 60;
tbHcell.BackColor = System.Drawing.Color.Black;
tbHcell.ForeColor = System.Drawing.Color.White;
tbHcell.BorderWidth = 1;
tbHcell.RowSpan = 2;
tbHcell.Text = "SNo";
tbr1.Cells.Add(tbHcell);
TableHeaderCell tbHcell1 = new TableHeaderCell();//Header Row for emp No
tbHcell1.Width = 100;
tbHcell1.BackColor = System.Drawing.Color.Black;
tbHcell1.ForeColor = System.Drawing.Color.White;
tbHcell1.BorderWidth = 1;
tbHcell1.RowSpan = 2;
tbHcell1.Text = "empno";
tbr1.Cells.Add(tbHcell1);
}
TableCell tbcell = new TableCell();// Row value for serial No
tbcell.Width = 60;
tbcell.BorderWidth = 1;
tbcell.Text = (i + 1).ToString();
tbrow.Cells.Add(tbcell);
TableCell tbcell1 = new TableCell();//Row value for emp No
tbcell1.Width = 100;
tbcell1.BorderWidth = 1;
tbcell1.Text = empno;
tbrow.Cells.Add(tbcell1);
TableHeaderCell tbHcell5 = new TableHeaderCell();//Tabel main Header from dt table rows
for (int j = 0; j < dt2.Rows.Count; j++)
{
if (i == 0)
{
TableHeaderCell tbHcell2 = new TableHeaderCell();//Tabel Header from dt table rows
tbHcell2.Width = 100;
tbHcell2.BackColor = System.Drawing.Color.Black;
tbHcell2.ForeColor = System.Drawing.Color.White;
tbHcell2.BorderWidth = 1;
tbHcell2.Text = dt2.Rows[j][1].ToString();
tbr.Cells.Add(tbHcell2);
if (lastvalue == dt.Rows[j][2].ToString())
{
k = k + 1;
}
else
{
tbHcell5 = new TableHeaderCell();//Tabel main Header with column Span from dt table rows
tbHcell5.Width = 100;
tbHcell5.BackColor = System.Drawing.Color.Black;
tbHcell5.ForeColor = System.Drawing.Color.White;
tbHcell5.BorderWidth = 1;
tbHcell5.Text = dt2.Rows[j][2].ToString();
tbr1.Cells.Add(tbHcell5);
lastvalue = dt2.Rows[j][2].ToString();
k = 1;
}
tbHcell5.ColumnSpan = k;
}
TableCell tbcell2 = new TableCell();//table row value from dt table row
tbcell2.Width = 100;
tbcell2.BorderWidth = 1;
tbcell2.Text = Convert.ToDouble(dt2.Rows[j][7]).ToString("N2");
tbrow.Cells.Add(tbcell2);
}
if (i == 0)
{
tb.Rows.Add(tbr1);
tb.Rows.Add(tbr);
}
tb.Rows.Add(tbrow);
}
Panel1.Controls.Add(tb);
}
Supoose We Have Table Employee
DataTable dt1;
DataTable dt2;
Table tb = new Table();
tb.CssClass = "mGrid";
Int32 k = 1;
string lastvalue = "";
for (int i = 0; i < dt.Rows.Count; i++)
{
String empNo = dt1.Rows[i][0].ToString();
TableRow tbrow = new TableRow();
TableRow tbr = new TableRow();
TableRow tbr1 = new TableRow();
if (i == 0)
{
TableHeaderCell tbHcell = new TableHeaderCell();//Header Row for Serial No
tbHcell.Width = 60;
tbHcell.BackColor = System.Drawing.Color.Black;
tbHcell.ForeColor = System.Drawing.Color.White;
tbHcell.BorderWidth = 1;
tbHcell.RowSpan = 2;
tbHcell.Text = "SNo";
tbr1.Cells.Add(tbHcell);
TableHeaderCell tbHcell1 = new TableHeaderCell();//Header Row for emp No
tbHcell1.Width = 100;
tbHcell1.BackColor = System.Drawing.Color.Black;
tbHcell1.ForeColor = System.Drawing.Color.White;
tbHcell1.BorderWidth = 1;
tbHcell1.RowSpan = 2;
tbHcell1.Text = "empno";
tbr1.Cells.Add(tbHcell1);
}
TableCell tbcell = new TableCell();// Row value for serial No
tbcell.Width = 60;
tbcell.BorderWidth = 1;
tbcell.Text = (i + 1).ToString();
tbrow.Cells.Add(tbcell);
TableCell tbcell1 = new TableCell();//Row value for emp No
tbcell1.Width = 100;
tbcell1.BorderWidth = 1;
tbcell1.Text = empno;
tbrow.Cells.Add(tbcell1);
TableHeaderCell tbHcell5 = new TableHeaderCell();//Tabel main Header from dt table rows
for (int j = 0; j < dt2.Rows.Count; j++)
{
if (i == 0)
{
TableHeaderCell tbHcell2 = new TableHeaderCell();//Tabel Header from dt table rows
tbHcell2.Width = 100;
tbHcell2.BackColor = System.Drawing.Color.Black;
tbHcell2.ForeColor = System.Drawing.Color.White;
tbHcell2.BorderWidth = 1;
tbHcell2.Text = dt2.Rows[j][1].ToString();
tbr.Cells.Add(tbHcell2);
if (lastvalue == dt.Rows[j][2].ToString())
{
k = k + 1;
}
else
{
tbHcell5 = new TableHeaderCell();//Tabel main Header with column Span from dt table rows
tbHcell5.Width = 100;
tbHcell5.BackColor = System.Drawing.Color.Black;
tbHcell5.ForeColor = System.Drawing.Color.White;
tbHcell5.BorderWidth = 1;
tbHcell5.Text = dt2.Rows[j][2].ToString();
tbr1.Cells.Add(tbHcell5);
lastvalue = dt2.Rows[j][2].ToString();
k = 1;
}
tbHcell5.ColumnSpan = k;
}
TableCell tbcell2 = new TableCell();//table row value from dt table row
tbcell2.Width = 100;
tbcell2.BorderWidth = 1;
tbcell2.Text = Convert.ToDouble(dt2.Rows[j][7]).ToString("N2");
tbrow.Cells.Add(tbcell2);
}
if (i == 0)
{
tb.Rows.Add(tbr1);
tb.Rows.Add(tbr);
}
tb.Rows.Add(tbrow);
}
Panel1.Controls.Add(tb);
}
Subscribe to:
Posts (Atom)