How to specify the hspace and vspace in a <asp:Image>?
VB.NET Image1.Attributes.Add(‘hspace’, ’50’) Image1.Attributes.Add(‘vspace’, ’50’) C# Image1.Attributes.Add(‘hspace’, ’50’) ; Image1.Attributes.Add(‘vspace’, ’50’) ;
How to check if the user is using a secure or non secure connection
The Request Object defines a Property called IsSecureConnection, that will indicate whether http:// or https:// has been used.
How to save a file in the client machine
The browser will not allow you to save a file directly to a client machine. You could however do a Response.Redirect(‘http://server/filename’); which would send the file back to the browser, at which point the user would be prompted to save / open the file.
I get the error message ‘Cast from type DBNull to type String is not valid.’ when I try to display DataReader values on form
Try VB.NET txtCountry.Text = dr(‘FieldName’).ToString() C# txtCountry.Text = dr[‘FieldName’].ToString(); or Try VB.NET If dbReader(‘fieldname’).ToString= DBnull.Value.ToString() ’Empty field value Else ’Display value End if C# if (dbReader[‘fieldname’).ToString() == DBNull.Value.ToString() ) { //Empty field value } else { //display Value }
How to store SortedList in Session or Cache
VB.NET Dim x As New SortedList() x.Add(‘Key1’, ‘ValueA’) x.Add(‘Key2’, ‘ValueB’) To store in Session: Session(‘SortedList1’) = x and to retrieve Dim y As SortedList = CType(Session(‘SortedList1’), SortedList) C# SortedList x = new SortedList(); x.Add(‘Key1’, ‘ValueA’); x.Add(‘Key2’, ‘ValueB’); To store in Session: Session[‘SortedList1’] = x; and to retrieve SortedList y = (SortedList) Session[‘SortedList1’];