Blog
Anchor (Add Link with in a Page)
24/06/2009 15:37To link to a location on the same page, you need two anchor tags.
Hyperlink Reference <a href=></a>
Name Tag <a name=></a>
This configuration is used for the common Back to Top link on HTML pages.
<a href="#destination_name">Destination</a>
<a name="destination_name"></a>
Designate Location on Another Page
The name tag can also be used to go to a designated location on another page. The name tag would be placed on the page at the desired location.
To link to that page and location the code would be:
<a href="samesite.htm#destination_name">Another Page</a>
———
Web Service and get Individual vaues from webservice
16/06/2009 16:36For Import webservice class
using net.webservicex.www;
ArrayList a = new ArrayList();
CurrencyConvertor cc = new CurrencyConvertor();
//Response.Write(cc.ConversionRate(Currency.USD, Currency.INR));
GlobalWeather g = new GlobalWeather();
Response.Write(g.GetCitiesByCountry("Pakistan"));
foreach (string s in Enum.GetNames(typeof(Currency)))
{
a.Add(s);
}
———
Cookies
03/06/2009 11:46Put Cookies in system:
HttpCookie hc = new HttpCookie("test");
hc.Values.Add("ip", System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName()).GetValue(0).ToString());
hc.Expires = DateTime.Now.AddSeconds(10);
Response.Cookies.Add(hc);
Get Cookies from System
string ip= Request.Cookies["test"]["ip"].ToString();
———
Get Client IP Address
03/06/2009 10:21Response.Write(System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName()).GetValue(0).ToString());
———
Reset Controls
02/06/2009 17:27 protected void ResetButton1_Click(object sender, EventArgs e)
{
ResetFormControlValues(this);
}
private void ResetFormControlValues(Control parent)
{
foreach (Control c in parent.Controls)
{
if (c.Controls.Count > 0)
{
ResetFormControlValues(c);
}
else
{
switch (c.GetType().ToString())
{
case "System.Web.UI.WebControls.TextBox":
((TextBox)c).Text = "";
break;
case "System.Web.UI.WebControls.CheckBox":
((CheckBox)c).Checked = false;
break;
case "System.Web.UI.WebControls.RadioButton":
((RadioButton)c).Checked = false;
break;
}
}
}
}
———
Cross Postback
02/06/2009 16:19Note: Use Linkbutton or Hyperlink for postback dont use Response.Redirect()
In Default4:
<%@ PreviousPageType VirtualPath="~/Default3.aspx" %>
In Default3.cs
private string getstr;
public string Getstr
{
get { return getstr; }
set { getstr = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
Getstr = "Jeyachandran";
}
In Default4.cs
Response.Write(((TextBox)Page.PreviousPage.FindControl("TextBox1")).Text);
Response.Write(PreviousPage.Getstr);
———
Online Polling
02/06/2009 16:04 static int count = 0;
static decimal countA = 0;
static decimal countB = 0;
decimal perA = 0;
decimal perB = 0;
protected void LinkButton1_Click(object sender, EventArgs e)
{
lblA.BackColor = Color.Blue;
//widthA = Convert.ToInt32(lblA.Width.Value);
count += 1;
countA += 1;
calA();
calB();
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
lblB.BackColor = Color.Red;
//widthB = Convert.ToInt32(lblB.Width.Value);
count += 1;
countB += 1;
calB();
calA();
}
void calB()
{
perB = (countB / count) * 100;
lblB.Text =Convert.ToInt32(perB).ToString() + "%";
lblB.Width = Convert.ToInt32(perB) * 4 * 1;
}
void calA()
{
perA = (countA / count) * 100;
lblA.Text =Convert.ToInt32(perA).ToString() + "%";
lblA.Width = Convert.ToInt32(perA) * 4 * 1;
}
———
Set Icon in Address Bar
22/05/2009 11:32Paste this code in <head> tag.
<link rel="shortcut icon" href=favicons.ico type="image/x-icon" />
———