Tuesday, January 24, 2006

Important ASP.Net Tips

Important ASP.Net Tips

1. Focusing on a certain control
Just type this code in the Body of the Html.

2. Encrypting Connection String

private string EncryptConnectionString(string connectionString){
Byte[] b = System.Text.ASCIIEncoding.ASCII.GetBytes(connectionString);
string encryptedConnectionString = Convert.ToBase64String(b);
return encryptedConnectionString;}
Once you got the encrypted connection string you can copy and paste it in the web.config file.

3. Decrypting Connection String
private string DecryptConnectionString(){
Byte[] b = Convert.FromBase64String(ConfigurationSettings.AppSettings["ConnectionString"]);
string decryptedConnectionString = System.Text.ASCIIEncoding.ASCII.GetString(b);
return decryptedConnectionString;
Important ASP.Net Tips

1. Smart navigation

Smart navigation is a little-known Internet Explorer feature that enables the individual controls on your Web forms to maintain focus between postback, as well as allows you to suppress that flicker that occurs as you load the new page.
To turn on this little-known feature, simply set the smartNavigation property of your ASPX page to True. You can also apply the property to all project pages, by adding the tag to the following location within your Web.config file:

2. Stopping Your User from Right-Clicking
Want to prevent your user from performing any of the other commands available by right-clicking on a Web page in Internet Explorer? It?s not foolproof, but this neat little HTML edit usually does the trick.Just alter the opening tag of your HTML to the following:

3. Pressing Enter key
Sometimes, you will notice, that, in an ASP.Net form, depending on the circumstances, pressing the 'Enter' key to submit the form does not work. To force this to happen for a particular button on your page, just put this in the Page_Load routine: Page.RegisterHiddenField("__EVENTTARGET", "button1") Then, change 'button1' to the ID of your particular button. Understand, of course, if your cursor is inside of a MultiLine textbox, the default action of the enter key is to create a new line in the textbox, so, if this basically works anywhere outside of that scenario.

No comments:

Breaking News