Why doesn’t changes made to some of my properties don’t get saved in the aspx file during design time?

Nested properties in your controls should be marked with the NotifyParentProperty(true) attribute in order for the designer to get notified that it’s value has changed. For example, the following property (SubProperty) declaration should include the above mentioned attribute, for the designer to persist changes to that property during design-time: myControl.SomeComplexProperty.SubProperty = ‘some value’;

Why doesn’t my properties tagged with the PersistenceMode.InnerProperty attribute get saved in the aspx file?

All string type properties get saved as attributes of the parent tag inspite of the InnerProperty attribute setting. In fact, setting the InnerProperty attribute might prevent the property from getting saved at all. For example, in the property declaration below: [C#] [ Category(‘Appearance’), NotifyParentProperty(true), PersistenceMode(PersistenceMode.Attribute), // This should always be Attribute, not anything else like InnerProperty. ] public string Text{get{return text;}set{text = value;}}

How to read text file in ASP.NET

Use namespace System.IO VB.NET Dim sr As StreamReader sr = File.OpenText(Server.MapPath(‘1.txt’)) Dim strContents As String = sr.ReadToEnd() ’To display normal raw contents Response.Write(strContents) ’To handle Carriage returns Response.Write(strContents.Replace(vbCrLf, ‘<br>’)) sr.Close() C# StreamReader sr = File.OpenText(Server.MapPath(‘1.txt’)); string strContents = sr.ReadToEnd(); //To display normal raw contents Response.Write(strContents); //To handle Carriage returns Response.Write(strContents.Replace(‘\n’ , ‘<br>’)); sr.Close();

How to read a html file in ASP.NET

Use namespace System.IO VB.NET Dim file As String = Server.MapPath(‘temp.html’) Dim sr As StreamReader Dim fi As New FileInfo(file) Dim input As String = ‘<pre>’ If File.Exists(file) Then sr = File.OpenText(file) input += Server.HtmlEncode(sr.ReadToEnd()) sr.Close() End If input += ‘</pre>’ Me.Label1.Text = input C# string file = Server.MapPath (‘temp.html’); StreamReader sr; FileInfo fi = new FileInfo(file); string input = ‘<pre>’; if(File.Exists(file)) { sr = File.OpenText(file); input += Server.HtmlEncode(sr.ReadToEnd()); sr.Close(); } input += ‘</pre>’; this.Label1.Text = input;

How to display the Attribute values in an XML Document in a DataGrid

products.xml <?xml version=’1.0′ standalone=’yes’?> <NewDataSet> <Product> <ProductID pcode=’P2′>2</ProductID> <ProductName>Chang</ProductName> <SupplierID>1</SupplierID> <CategoryID>1</CategoryID> <QuantityPerUnit>24 – 12 oz bottles</QuantityPerUnit> </Product> <Product> <ProductID pcode=’P4′>3</ProductID> <ProductName>Aniseed Syrup</ProductName> <SupplierID>1</SupplierID> <CategoryID>2</CategoryID> <QuantityPerUnit>12 – 550 ml bottles</QuantityPerUnit> </Product> </NewDataSet> Use Namespace System.Xml VB.NET <asp:DataGrid id=’DataGrid1′ AutoGenerateColumns=’False’ runat=’server’> <Columns> <asp:TemplateColumn HeaderText=’ProductCode’> <ItemTemplate> <%#CType(Container.DataItem, System.Xml.XmlNode).Attributes(‘pcode’).value%> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> dim xmldoc as XmlDocument = new XmlDocument() xmldoc.Load(Server.MapPath(‘products.xml’)) dim xmlnodes as XmlNodeList = xmldoc.SelectNodes(‘NewDataSet/Product/ProductID’) DataGrid1.DataSource = xmlnodes DataGrid1.DataBind () C# <asp:DataGrid id=’DataGrid1′ AutoGenerateColumns=’False’ runat=’server’> <Columns> <asp:TemplateColumn HeaderText =’ProductCode’> <ItemTemplate> <%# ((System.Xml.XmlNode)Container.DataItem).Attributes[‘pcode’].Value %> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(Server.MapPath(‘products.xml’)); XmlNodeList xmlnodes = xmldoc.SelectNodes(‘NewDataSet/Product/ProductID’); DataGrid1.DataSource = xmlnodes; DataGrid1.DataBind ();