System.Web.HttpBrowserCapabilities browser = Request.Browser;
string browserset = "Browser Capabilities\n"
+ "Type = " + browser.Type + "\n"
+ "Name = " + browser.Browser + "\n"
+ "Version = " + browser.Version + "\n"
+ "Major Version = " + browser.MajorVersion + "\n"
+ "Minor Version = " + browser.MinorVersion + "\n"
+ "Platform = " + browser.Platform + "\n"
+ "Is Beta = " + browser.Beta + "\n"
+ "Is Crawler = " + browser.Crawler + "\n"
+ "Is AOL = " + browser.AOL + "\n"
+ "Is Win16 = " + browser.Win16 + "\n"
+ "Is Win32 = " + browser.Win32 + "\n"
+ "Supports Frames = " + browser.Frames + "\n"
+ "Supports Tables = " + browser.Tables + "\n"
+ "Supports Cookies = " + browser.Cookies + "\n"
+ "Supports VBScript = " + browser.VBScript + "\n"
+ "Supports JavaScript = " +
browser.EcmaScriptVersion.ToString() + "\n"
+ "Supports Java Applets = " + browser.JavaApplets + "\n"
+ "Supports ActiveX Controls = " + browser.ActiveXControls
+ "\n";
Sunday, November 21, 2010
Detect browser name in ASP.NET
System.Web.
HttpBrowserCapabilities browser = Request.Browser;string s = "Browser Capabilities\n"+ "Type = " + browser.Type + "\n"+ "Name = " + browser.Browser + "\n"+ "Version = " + browser.Version + "\n"+ "Major Version = " + browser.MajorVersion + "\n"+ "Minor Version = " + browser.MinorVersion + "\n"+ "Platform = " + browser.Platform + "\n"+ "Is Beta = " + browser.Beta + "\n"+ "Is Crawler = " + browser.Crawler + "\n"+ "Is AOL = " + browser.AOL + "\n"+ "Is Win16 = " + browser.Win16 + "\n"+ "Is Win32 = " + browser.Win32 + "\n"+ "Supports Frames = " + browser.Frames + "\n"+ "Supports Tables = " + browser.Tables + "\n"+ "Supports Cookies = " + browser.Cookies + "\n"+ "Supports VBScript = " + browser.VBScript + "\n"+
browser.EcmaScriptVersion.ToString() + "Supports JavaScript = " +"\n"+ "Supports Java Applets = " + browser.JavaApplets + "\n"+
+ "Supports ActiveX Controls = " + browser.ActiveXControls"\n";
HttpBrowserCapabilities browser = Request.Browser;string s = "Browser Capabilities\n"+ "Type = " + browser.Type + "\n"+ "Name = " + browser.Browser + "\n"+ "Version = " + browser.Version + "\n"+ "Major Version = " + browser.MajorVersion + "\n"+ "Minor Version = " + browser.MinorVersion + "\n"+ "Platform = " + browser.Platform + "\n"+ "Is Beta = " + browser.Beta + "\n"+ "Is Crawler = " + browser.Crawler + "\n"+ "Is AOL = " + browser.AOL + "\n"+ "Is Win16 = " + browser.Win16 + "\n"+ "Is Win32 = " + browser.Win32 + "\n"+ "Supports Frames = " + browser.Frames + "\n"+ "Supports Tables = " + browser.Tables + "\n"+ "Supports Cookies = " + browser.Cookies + "\n"+ "Supports VBScript = " + browser.VBScript + "\n"+
browser.EcmaScriptVersion.ToString() + "Supports JavaScript = " +"\n"+ "Supports Java Applets = " + browser.JavaApplets + "\n"+
+ "Supports ActiveX Controls = " + browser.ActiveXControls"\n";
Function to check browser name in javascript
function check_browser()
{
try
{
var browserName=navigator.appName;
var browserVer=parseInt(navigator.appVersion);
if ((navigator.userAgent.indexOf('MSIE') != -1) && browserVer>=4)
{
browser_name='IE';
}
else if((navigator.userAgent.indexOf('Chrome') != -1) && browserVer>=4)
{
browser_name='Chrome';
}
else
{
browser_name='FireFox';
}
}
}
{
try
{
var browserName=navigator.appName;
var browserVer=parseInt(navigator.appVersion);
if ((navigator.userAgent.indexOf('MSIE') != -1) && browserVer>=4)
{
browser_name='IE';
}
else if((navigator.userAgent.indexOf('Chrome') != -1) && browserVer>=4)
{
browser_name='Chrome';
}
else
{
browser_name='FireFox';
}
}
}
Tuesday, November 16, 2010
Displaying Warning Message
link.Attributes.Add("onclick","return confirm('Are you sure you want to delete this data?');");
Monday, November 15, 2010
Set Date Format In Label Witth Data Binding
where date is a database field
We can also set it as
<asp:Label ID="Label1" runat="server" Text='<%= String.Format("{specifier}", DateTime.Now)%'></asp:Label>
Text='<%# Eval("date","{0:M}"<asp:Label ID="Label1" runat="server" Text='<%# Eval("date","{0:M}")%>'></asp:Label>
Tuesday, November 9, 2010
Set Character length of linkbutton
<asp:LinkButton ID="linknews" ForeColor="Black" Font-Underline="false" runat="server" Text='<%# Eval("news").ToString().Substring(0,80)%>'></asp:LinkButton>
Select Substring Query in sql server
SELECT
(CASE WHEN LEN( address) > 25
THEN SUBSTRING(address,0,25)
ELSE address END
)as address
FROM emp_details
(CASE WHEN LEN( address) > 25
THEN SUBSTRING(address,0,25)
ELSE address END
)as address
FROM emp_details
Tuesday, November 2, 2010
XML NODE TRAVERSE IN ASP.NET
public void TravelNode(XmlNode n)
{
TravelNode(n, 0);
}
public void TravelNode(XmlNode n, int i)
{
foreach (XmlAttribute attr in n.Attributes)
{
string v = attr.Name;
string na = attr.Value;
if (v == "Code")
{
status = "Not Delievered";
break;
}
else
{
status = "Delievered";
}
}
foreach (XmlNode nod in n.ChildNodes)
{
TravelNode(nod, i + 1);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
String dr="<?xml%20version=\"1.0\"%20encoding=\"ISO-8859-1\"?><!DOCTYPE%20REQUESTCREDIT%20SYSTEM%20\"http://107.10.10.01/dtd/requestcredit.dtd\"%20>";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(dr);
TravelNode(xmlDoc.DocumentElement);
}
READ XML DOCUMENT IN ASP.NET
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net;
using System.IO;
using System.Xml;
Stream objStream = null;
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(data);
try
{
objStream = wrGETURL.GetResponse().GetResponseStream();
}
catch (Exception ex)
{
ex.ToString();
}
StreamReader sr = new StreamReader(objStream);
string dr = sr.ReadToEnd();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(dr);
foreach (XmlNode nod in xmlDoc.DocumentElement)
{
foreach(XmlAttribute attr in nod.Attributes)
{
string na = attr.Name;
string v = attr.Value;
if (na.Equals("Limit"))
{
LblLimitName.Text = na;
LblLimitValue.Text = v;
}
else if(na.Equals("Used"))
{
LblUsedName.Text = na;
LblUsedValue.Text = v;
}
}
}
sr.Close();
objStream.Close();
Change Image Align,Image URL,Width,Height Programatically
protected void Page_Load(object sender, EventArgs e)
{
Image img = new Image();
img.ImageUrl = ds.Tables[0].Rows[0]["image"].ToString();
img.ImageAlign = ImageAlign.Left;
img.Width = new Unit("100px");
img.Height = new Unit("50px");
}
{
Image img = new Image();
img.ImageUrl = ds.Tables[0].Rows[0]["image"].ToString();
img.ImageAlign = ImageAlign.Left;
img.Width = new Unit("100px");
img.Height = new Unit("50px");
}
Monday, November 1, 2010
INSERT THE AUTO INCREMENTED COLUMN IN GRIDVIEW
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="AUTOINCREMENT FIELD">
<ItemTemplate>
<asp:Label ID="Label1" runat="server"><%# Container.DataItemIndex + 1 %></asp:Label></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
USE the DataItemIndex Property
<Columns>
<asp:TemplateField HeaderText="AUTOINCREMENT FIELD">
<ItemTemplate>
<asp:Label ID="Label1" runat="server"><%# Container.DataItemIndex + 1 %></asp:Label></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
USE the DataItemIndex Property
SET DATE TIME FORMAT IN GRIDVIEW
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"><Columns><asp:BoundField DataField="date" DataFormatString="{0:d}" HeaderText="Date" /></Columns>
</asp:GridView>
</asp:GridView>
Subscribe to:
Posts (Atom)