In this Article, I will provide a few tips in problem and solution manner.
Opening an ASPX page in Visual studio 2003 is very slow.
To make it fast, please do follow below steps:
Open the Solution/Project.
Right click the ASPX file to be opened.
Select Open with…
Choose HTML Design Editor.
Click Set as Default option.
Restart the Visual studio.
Double clicking an ASPX page will now open faster.
Remembering connection string is difficult.
No need to remember the connection string. Follow below steps:
Open notepad. Save as “AnyName.udl”.
Open the created UDL file.
This will pop up Database selector window. Choose the database you would like to connect and give proper credentials.
Test the connection.
Once success, Open the UDL file with notepad the connection string will be there.
Don’t know the namespace for a particular class in Visual studio 2005.
You know the class name but not sure in which namespace it resides? (Say for Example NameValueCollection)
Type the classname in the .cs file (code behind for the ASP.NET page).
Right click the class name.
From the context menu select Resolve. The namespace will be added in the using namespace lists.
Your child ASPX page is not getting refreshed properly.
You might have opened a child page using window.open or some other method and passed some data from the parent page to the child page using QueryString for example. Subsequently, the child page may not populate the data based on the values passed by parent page. This is because the data passed is cached in the child browser. This could be avoided by passing Random value (e.g., querystring = querystring + “&Random=” + Math.random()) as one of the argument in query string. This will refresh the child page each time.
Need to share values between parent and child page in JavaScript.
Sometimes you may load child pages (using iFrame or Tab) in parent page. The value can be shared easily between parent and child pages using global variables in parent page. The variable can be accessed in child page using:
Need to find out the protocol correctly of your page.
The serverside approach (Request.Url) to find out the protocol in a website (HTTP or HTTPS) may be error prone on a production server. This could be resolved using Clientside code (JavaScript)
window.location.href will give the full path of the requested file. We could parse and get the protocol from the above value.
Need to toggle between ASPX page blocks in client side.
// It will hide the controls specified in the iddocument.getElementByID (‘id’).style.display = “none”; // It will show the controls specified in the iddocument.getElementByID (‘id’).style.display = “block”;
Need to add a JavaScript element dynamically in an ASPX page.
function CreateElement (ele){ var e = document.createElement(ele); e.[Attribute1] = [Value1]; e.[Attribute2] = [Value2]; // This can be changed wherever you like to append the created element document.getElementsByTagName("head")[0].appendChild(e); }
Need to show print dialog without showing the content page to the user.
On a button click we need to show only the print dialog not the content page. This can be accomplished using iFrame in client side.
1. Have the ASPX page that having the content to be printed (e.g., PrintPage.aspx). This page should call
window.print() in its client side to launch the print dialog.
4. In the click event of the Print button write below code:
//Show the iFramedocument.getElementByID (‘frmPrint’).style.display = “block”; //Load the page to launch the print dialogdocument.getElementByID (‘frmPrint’).src = “PrintPage.aspx”; //Hide the iFramedocument.getElementByID (‘frmPrint’).style.display = “none”;
Our community of experts have been thoroughly vetted for their expertise and industry experience. Experts with Gold status have received one of our highest-level Expert Awards, which recognize experts for their valuable contributions.
I love resolution of types. It is good even when you know the namespace of the types you are using, but like to type out the names sometimes and then use this technique to automatically add the using clauses. Occasionally, you will run into multiple choices where a class uses a common name that belongs to multiple namespaces, but typically as developers we should know which one we intended. What I find as a nice backup is the Object Browser where I can see that a particular implementation has the methods/properties I intended to use.
Anyway, nice job!
Regards,
Kevin
Have a question about something in this article?
You can receive help directly from the article author.
Sign up for a free trial to get started.
Comments (1)
Commented:
For connection strings, I use this nice reference also: http://www.connectionstrings.com/
I love resolution of types. It is good even when you know the namespace of the types you are using, but like to type out the names sometimes and then use this technique to automatically add the using clauses. Occasionally, you will run into multiple choices where a class uses a common name that belongs to multiple namespaces, but typically as developers we should know which one we intended. What I find as a nice backup is the Object Browser where I can see that a particular implementation has the methods/properties I intended to use.
Anyway, nice job!
Regards,
Kevin