How to implement authentication via web.config
Include the <authorization> element. <authorization> <deny users='?'/> </authorization>
Why do I get the Compiler Error Message: ‘CS0246: The type or namespace name ‘…’ could not be found (are you missing a using directive or an assembly reference?) ‘
This problem typically comes when: You do not have class with that name in your project You add the class later on and run the project without compiling You have the class but you do not specify the namespace via Imports or using keyword
How to set the background color of a web page using code behind?
Yes In the body tag, add runat=’server’ and give the tag an id (e.g. id=’bodyID’). In the class definition in the code-behind, add VB.NET Protected bodyID As System.Web.UI.HtmlControls.HtmlGenericControl C# protected System.Web.UI.HtmlControls.HtmlGenericControl bodyID ; In code, use the attributes collection to set the bgcolor attribute: VB.NET bodyID.Attributes.Add('bgcolor', 'green') C# bodyID.Attributes.Add('bgcolor', 'green');
How to loop through a Dataset to display all records
VB.NET ’Fill Dataset Dim dc As DataColumn Dim dr As DataRow For Each dr In ds.Tables(0).Rows For Each dc In ds.Tables(0).Columns Response.Write(dr(dc.ColumnName).ToString()) Next Next C# //Fill the DataSet foreach (DataRow dr in ds.Tables[0].Rows) { foreach( DataColumn dc in ds.Tables[0].Columns) { Response.Write(dr[dc.ColumnName].ToString()); } }
How to display errors using Page_Error event of Page Object
VB.NET Private Sub Page_Error(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Error Response.Write(Server.GetLastError().ToString) Server.ClearError() End Sub C# //In InitializeComponent this.Error += new System.EventHandler (this.Page_Error ); // private void Page_Error(object sender, System.EventArgs e ) { Response.Write(Server.GetLastError().ToString()); Server.ClearError (); } In the Same manner handle the Errors in the Application_Error event in global.asax