TIPS and TRICKS for DOT NET
Tips & Tricks for Dotnet
1) Incremental search in Visual Studio.
1. Press Ctrl+I.
2. Start typing the text you are searching for. Note: you’ll see the cursor jump to the first match, highlighting the current search string.
3. Press Ctrl+I again to jump to the next occurrence of the search string.
4. To stop search, press Esc. Advanced tip: Press Ctrl+Shift+I to search backwards.
2) Make Window Fit any Resolution
Create function definition
function resolution()
{
UserWidth = window.screen.availWidth
UserHeight = window.screen.availheight
window.resizeTo(UserWidth, UserHeight)
window.moveTo(0,0)
}
2) Call the function on load event of body.
3) Adding a Print Button with Javascript
Add this line to the Page_Load event
btnPrint.Attributes(”onClick”) =”javascript:window.print();”
*Add a button to the page called ‘btnPrint’ Technically, that’s it, but, let’s say you want to do something a little fancier, using DotNet.
Then, add a subroutine (let’s call it ‘DoPrint’):
Sub doPrint(Source as Object, E as EventArgs)
lblResults.visible=”True”
lblResults.text=”Page has successfully been sent to the printer!”
End Sub
Then, add a direction to this sub, in the button’s tag: onServerclick=”doPrint”
4) *To print certain areas of a page
Create a style sheet for printing purpose, normally by removing/hiding background colors, images…. After that include it with media=”print”,
so that this style sheet will be applied while printing.
5)Disabling a Button Until Processing is Complete
Here’s the scenario - let’s say you have an Insert subroutine,
called ‘doInsert’.
You want to immediately disable the Submit button, so that the end-user won’t click it multiple times, therefore, submitting the same data multiple times. For this,
use a regular HTML button, including a Runat=”server” and an ‘OnServerClick’ event designation - like this:
Then, in the very last line of the ‘doInsert’ subroutine, add this line: Button1.enabled=”True”
