July 30, 2012

JavaScript to Open PopUp on Hyperlink

Hyperlink1.Attributes.Add("onclick", "window.open('popup.aspx',null,'height=250, width=250,status= no, resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');")

July 24, 2012

Detect Browser Types and Browser Capabilities in ASP.NET Web Pages


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"
            + "Supports JavaScript = " +
                browser.EcmaScriptVersion.ToString() + "\n"
            + "Supports Java Applets = " + browser.JavaApplets + "\n"
            + "Supports ActiveX Controls = " + browser.ActiveXControls
                  + "\n"
            + "Supports JavaScript Version = " +
                browser["JavaScriptVersion"] + "\n";

July 18, 2012

Microsoft JScript runtime error: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the AjaxScriptManager in System.Web.Ajax.dll, or use the ToolkitScriptManager in AjaxControlToolkit.dll.



I believe there are many other problems which can cause this symptom, but in my case, as the error message says, the solution is that you need to include the “ToolkitScriptManager” rather than the standard “ScriptManager”

To add the ToolkitScriptManager, you first need to include the assembly namespace on your aspx page.

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"
TagPrefix="asp" %>
If you control is right on your main page, chances are you have already done this.  But in my case the Ajax control was embedded in a user control, so I didn’t have it on the main page yet.

Then you can simply include the manager by changing the standard script manager

<asp:ScriptManager ID="scriptMaster" runat="server"></asp:ScriptManager>
to this:

<asp:ToolkitScriptManager ID="toolkitScriptMaster" runat="server">
</asp:ToolkitScriptManager>

Create a View in SQL


CREATE VIEW  vwEmployee
AS  
Select  EmployeeCode , EmployeeName , Designation   from  Employee

July 11, 2012

Optimizing Sql Query


Select d.NAME, e.NAME
From DEPT d, EMP e
where  d.MGR = e.SS# 

or:
Select  d.NAME, e.NAME 
From EMP e, DEPT d 
where  d.MGR = e.SS# 


Suppose that there are 10 departments and 1000 employees, and that the inner table in each query has an index on the join column. In the first query, the first table produces 10 qualifying rows (in this case, the whole table). In the second query, the first table produces 1000 qualifying rows. The first query will access the EMP table 10 times and scan the DEPT table once. The second query will scan the EMP table once but will access the DEPT table 1000 times. Therefore the first query will perform much better.

 As a rule of thumb, tables should be arranged from smallest effective number rows to largest effective number of rows. The effective row size of a table in a query is obtained by applying the logical conditions that are resolved entirely on that table.

July 6, 2012

Gridview RowDatabound Event


 <asp:BoundField DataField="IssCode" Visible = "False" HeaderText = "Issuecode">
</asp:BoundField>



protected void gvIPOReport_RowCommand(object sender, GridViewCommandEventArgs e)
{
  if (Session["UserId"] != null)
{
  if (e.CommandName == "DeleteRow")
{
  GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
string ApplyId = gvIPOReport.DataKeys[row.RowIndex].Value.ToString();
string IssueCode = gvIPOReport.Rows[row.RowIndex].Cells[13].Text.ToString();         
DataAccess oData = new DataAccess();
int iCount = oData.DeleteApplicationDetails(ApplyId,   Session["UserId"].ToString().Trim().ToUpper(), IssueCode);
if (iCount > 0)
{
  FillGrid();
 
}
  else
{


}
  }
  }
  else
{
  lblErrorMessage.Text = "Session Expired Please login again.";
}
 }