How do I debug JavaScript and other script code in my application using Visual Studio .Net?

1) In IE go to Tools/Internet Options…/Advanced Tab and clear the ‘Disable Script Debugging’ check box options. 2) In VS.Net in your project properties dialog, select ‘Debugging’ under ‘Configuration Properties’ and make sure that ‘Enable ASP.Net Debugging’ is turned on. 3) You can then set break points in script code in VS.Net in custom script files or the application aspx file. 4) VS.Net should give you detailed debugging information for variables in the scope just like other high-level languages.

How to convert a string to HTML format

Use namespace System.Web.HttpUtility VB.NET Dim mystring as string =”Tom & Jerry” Response.Write (HttpUtility.HtmlDecode (mystring)) C# string mystring=”Tom & Jerry”; Response.Write (HttpUtility.HtmlDecode (mystring));

How to read the comma separated values from a string

VB.NET Dim myString As String = ‘A, B, C, D’ Dim delimStr As String = ‘ ,’ Dim delimiter As Char() = delimStr.ToCharArray() Dim s As String For Each s In myString.Split(delimiter) Response.Write((s.ToString() + ‘<br>’)) Next C# string myString = ‘A, B, C, D’; string delimStr = ‘ ,’; char[] delimiter = delimStr.ToCharArray(); foreach (string s in myString.Split(delimiter)) { Response.Write (s.ToString ()+ ‘<br>’); }

How to set a <link> tag’s href attribute at runtime using a value specified in the web.config file

web.config <configuration> <appSettings> <add key=’CSS1′ value=’StyleSheet1.css’ /> </appSettings> </configuration> .aspx <link id=’link1′ runat=’server’/> VB.NET Dim lnk As New System.Web.UI.HtmlControls.HtmlGenericControl(‘lnk’) lnk = CType(Me.Page.FindControl(‘link1’), System.Web.UI.HtmlControls.HtmlGenericControl) lnk.Attributes.Add(‘rel’, ‘stylesheet’) lnk.Attributes.Add(‘href’, ConfigurationSettings.AppSettings(‘CSS1’).ToString()) lnk.Attributes.Add(‘type’, ‘text/css’) C# System.Web.UI.HtmlControls.HtmlGenericControl lnk =new System.Web.UI.HtmlControls.HtmlGenericControl (‘lnk’) ; lnk =(System.Web.UI.HtmlControls.HtmlGenericControl ) this.Page.FindControl( ‘link1’) ; lnk.Attributes.Add (‘rel’, ‘stylesheet’); lnk.Attributes.Add (‘href’, ConfigurationSettings.AppSettings[‘CSS1’].ToString()) ; lnk.Attributes.Add (‘type’,’text/css’);

How to dynamically load User Controls

Create a User Control <P> <asp:Button id=’Button1′ runat=’server’ Text=’Button’></asp:Button></P> <P> <asp:Label id=’Label1′ runat=’server’></asp:Label></P> On button Click VB.NET Label1.Text = ‘Hello’ C# Label1.Text = ‘Hello’ ; Create a Webform to use a UserControl <asp:Panel id=’Panel1′ runat=’server’></asp:Panel> VB.NET Dim myControl As Control = CType(Page.LoadControl(‘UC1.ascx’), Control) Panel1.Controls.Add(myControl) C# Control myControl =(Control)Page.LoadControl(‘UC1.ascx’); Panel1.Controls.Add(myControl);