Why does my page show up poorly in Mozilla based browsers like Netscape and Firefox?

The .Net framework recognizes the capabilities of the latest version of the above browsers poorly. This is because, by default, the BrowserCaps section of the machine.config file (usually found under a folder like ‘C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFIG’) declares the capabilities of the Mozilla based browser poorly. So, you will have to replace the default entry in your install with this one: Mozilla BrowserCaps. In case the above link didn’t work, this is the content from the above link, captured as of (4/10/2005): <browserCaps> <!– Name: BrowserCaps update for modern browsers, http://slingfive.com/pages/code/browserCaps/ Author: Rob Eberhardt, http://slingfive.com/ History: 2004-11-19 improved detection of Safari, Konqueror & Mozilla variants, added Opera detection 2003-12-21 updated TagWriter info 2003-12-03 first published –> <!– GECKO Based Browsers (Netscape 6+, Mozilla/Firefox, …) //–> <case match=’^Mozilla/5\.0 \([^)]*\) (Gecko/[-\d]+)(?’VendorProductToken’ (?’type’[^/\d]*)([\d]*)/(?’version’(?’major’\d+)(?’minor’\.\d+)(?’letters’\w*)))?’> browser=Gecko <filter> <case match='(Gecko/[-\d]+)(?’VendorProductToken’ (?’type’[^/\d]*)([\d]*)/(?’version’(?’major’\d+)(?’minor’\.\d+)(?’letters’\w*)))’> type=${type} </case> <case> type=Mozilla </case> </filter> frames=true tables=true cookies=true javascript=true javaapplets=true ecmascriptversion=1.5 w3cdomversion=1.0 css1=true css2=true xml=true tagwriter=System.Web.UI.HtmlTextWriter <case match=’rv:(?’version’(?’major’\d+)(?’minor’\.\d+)(?’letters’\w*))’> version=${version} majorversion=0${major} minorversion=0${minor} <case match=’^b’ with=’${letters}’> beta=true </case> </case> </case> <!– AppleWebKit Based Browsers (Safari…) //–> <case match=’AppleWebKit/(?’version’(?’major’\d?)(?’minor’\d{2})(?’letters’\w*)?)’> browser=AppleWebKit version=${version} majorversion=0${major} minorversion=0.${minor} frames=true tables=true cookies=true javascript=true javaapplets=true ecmascriptversion=1.5 w3cdomversion=1.0 css1=true css2=true xml=true tagwriter=System.Web.UI.HtmlTextWriter <case match=’AppleWebKit/(?’version’(?’major’\d)(?’minor’\d+)(?’letters’\w*))(.* )?(?’type’[^/\d]*)/.*( |$)’> type=${type} </case> </case> <!– Konqueror //–> <case match=’.+[K|k]onqueror/(?’version’(?’major’\d+)(?’minor’(\.[\d])*)(?’letters’[^;]*));\s+(?’platform’[^;\)]*)(;|\))’> browser=Konqueror version=${version} majorversion=0${major} minorversion=0${minor} platform=${platform} type=Konqueror frames=true tables=true cookies=true javascript=true javaapplets=true ecmascriptversion=1.5 w3cdomversion=1.0 css1=true css2=true xml=true tagwriter=System.Web.UI.HtmlTextWriter </case> <!– Opera //–> <case match=’Opera[ /](?’version’(?’major’\d+)(?’minor’\.(?’minorint’\d+))(?’letters’\w*))’> <filter match='[7-9]’ with=’${major}’> tagwriter=System.Web.UI.HtmlTextWriter </filter> <filter> <case match=’7′ with=’${major}’> <filter> <case match='[5-9]’ with=’${minorint}’> ecmascriptversion=1.5 </case> <case> ecmascriptversion=1.4 </case> </filter> </case> <case match='[8-9]’ with=’${major}’> ecmascriptversion=1.5 </case> </filter> </case> </browserCaps>

How to validate a CheckBox

<asp:CheckBox runat=’server’ id=’chkbox’></asp:CheckBox> <asp:CustomValidator runat=’server’ ErrorMessage=’Error!’ OnServerValidate=’ServerValidation’ ClientValidationFunction=’ClientValidation’ ID=’Customvalidator1′ /> <asp:Button runat=’server’ text=’submit’ ID=’Button1′ /> <script language=’javascript’> function ClientValidation(source, args) { args.IsValid = document.all[‘chkbox’].checked; } </script> VB.NET <script runat=’server’ language=’vb’> sub ServerValidation( source as object, args as ServerValidateEventArgs ) args.IsValid = chkbox.Checked end sub </script> C# <script runat=’server’ language=’cs’> void ServerValidation(object source, ServerValidateEventArgs args) { args.IsValid = chkbox.Checked; } </script>

Which control should I use when binding a multidimensional array

Use a DataList as follows. .aspx <asp:datalist id=’DataList1′ runat=’server’> <ItemTemplate> <asp:repeater datasource='<%#Container.DataItem%>’ runat=server ID=’Repeater1′ > <ItemTemplate> <%# Container.DataItem %> </ItemTemplate> </asp:repeater> </ItemTemplate> </asp:datalist> VB.NET Private Sub Page_Load(sender As Object, e As System.EventArgs) ’ Put user code to initialize the page here ’ Create and populate a multi-dimensional array Dim MyArray(4) As Integer() Dim i As Integer For i = 0 To 3 MyArray(i) = New Integer(5) {} Dim x As Integer For x = 0 To 4 MyArray(i)(x) = x + 5 * i Next Next DataList1.DataSource = MyArray DataList1.DataBind() End Sub ’Page_Load C# private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here // Create and populate a multi-dimensional array int [][] MyArray = new int[4][]; for (int i=0; i<4; i++) { MyArray[i] = new int[5]; for (int x=0; x<5; x++) { MyArray[i][x] = x+(5*i); } } DataList1.DataSource = MyArray; DataList1.DataBind(); }

How to create a File Picker in ASP.NET

Use namespace System.IO <asp:label id=’lblHeader’ runat=’server’></asp:label><br> <b>Get Information on Directory:</b><br> <p><asp:textbox id=’txtPath’ runat=’server’></asp:textbox> <p></p> <asp:button id=’btnSubmit’ runat=’server’ text=’Go!’ type=’Submit’></asp:button> <p></p> <div style=’width:100%; height:200; overflow:auto;’> <asp:datalist id=’DataList1′ runat=’server’ DataKeyField=’FullName’ OnSelectedIndexChanged=’SelectedIndexChanged’> <ItemTemplate> <li> <%# DataBinder.Eval(Container.DataItem, ‘Name’) %> <br> <font size=’-1′>[ <asp:linkbutton Text=’View Contents’ CommandName=’Select’ runat=’server’ ID=’Linkbutton1′ />] | [ <%# DataBinder.Eval(Container.DataItem, ‘Length’) %> bytes] </font> <p> </ItemTemplate> </asp:datalist> </div> <p> <hr> </p><asp:label id=’lblFileContents’ runat=’server’></asp:label> VB.NET Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ’Put user code to initialize the page here If Request(‘txtPath’) <> ” Then Dim strDir As String = Request(‘txtPath’) lblHeader.Text = ‘File Listing for ‘ & strDir & ” Dim dirInfo As New DirectoryInfo(strDir) ’ Get the files for the directory strDir Dim fInfos As FileInfo() = dirInfo.GetFiles(‘*.*’) DataList1.DataSource = fInfos DataList1.DataBind() End If End Sub Protected Sub SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataList1.SelectedIndexChanged Dim strFilePath As String = DataList1.DataKeys(DataList1.SelectedItem.ItemIndex).ToString() Dim fInfo As FileInfo = New FileInfo(strFilePath) Dim objStream As StreamReader = fInfo.OpenText() Dim strContents As String = objStream.ReadToEnd() objStream.Close() lblFileContents.Text = ‘Contents of ‘ & fInfo.Name & ‘:’ & _ ” & vbCrLf & strContents & vbCrLf & ” End Sub C# private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (Request[‘txtPath’]!= null) { string strDir = Request[‘txtPath’]; lblHeader.Text = ‘File Listing for ‘ + strDir + ”; DirectoryInfo dirInfo =new DirectoryInfo(strDir); // Get the files for the directory strDir FileInfo[] fInfos = dirInfo.GetFiles(‘*.*’); DataList1.DataSource = fInfos; DataList1.DataBind(); } } protected void SelectedIndexChanged(Object sender , System.EventArgs e ) { string strFilePath = DataList1.DataKeys[(int)DataList1.SelectedItem.ItemIndex].ToString(); FileInfo fInfo = new FileInfo(strFilePath); StreamReader objStream = fInfo.OpenText(); string strContents = objStream.ReadToEnd(); objStream.Close(); lblFileContents.Text = ‘Contents of ‘ + fInfo.Name + ‘:’ + ” + ‘ ‘ + strContents + ‘ ‘ + ”; }

How can I get a list of all the environment variables

VB.NET <asp:DataList id=’DataList1′ runat=’server’> <HeaderTemplate> <table> </HeaderTemplate> <ItemTemplate> <tr> <td> <%# CType(Container.DataItem, DictionaryEntry).Key %> </td> <td> <%# CType(Container.DataItem, DictionaryEntry).Value%> </td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:DataList> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ’Put user code to initialize the page here DataList1.DataSource = System.Environment.GetEnvironmentVariables() DataList1.DataBind() End Sub C# <asp:DataList id=’DataList1′ runat=’server’> <HeaderTemplate> <table> </HeaderTemplate> <ItemTemplate> <tr> <td> <%# ((DictionaryEntry)Container.DataItem).Key %> </td> <td> <%# ((DictionaryEntry)Container.DataItem).Value %> </td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:DataList> private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here DataList1.DataSource = System.Environment.GetEnvironmentVariables(); DataList1.DataBind(); }