.Net Tips & Trick – Your Daily Productivity Tips

Daily .NET Tips A single tip can improve the productivity of work while coding. Daily .NET Tips is aiming to share useful coding tips and tricks for .net developers. The primary goal of this site is to provide quality tips, tricks, sharing new features, .net How to’s, .net gotchas, .net FAQ and the useful code snippet that may help you in daily development work. This site is targeted for all beginner to advanced level of .net developers. You will find tips and posts from the beginners level to higher level. However, there is no categorization provided in the tips difficulties level. Finally, it is up to you,  how you are applying it into your day to day job based on your level of expertise.  If you are preparing for any .net interview, this site material may tremendous help to you.  What else, visit Daily .NET Tips, and improve your development productivity.

 

Why Daily .NET Tips ?

It all starts from here! Yes, from this Page!  I wrote few tips related with .net/ Visual Studio – a long back! I got the tremendous response and many requests for writing more and more tips that help the developer in their day to day working.
Thanks for your continuous encouragement on the tips I have shared related to .net technologies over here.  To take the series of tips in a next step, “.NET Tips” is now moved to a new site.

“Daily .NET Tips” – Daily Developer Productivity Tips !

Please Visit : http://dailydotnettips.com For Daily Tips on .NET. for getting daily updates on .NET Tips!

Here is the list of old tips.

How to select Block of Code in Visual Studio?

You can select line by line code very easily using mouse or keyboard. But if you want to copy some code block where you don’t to select all part of line or something like that, here is a Quick TIP For you. Press and HoldAlt” Key, and select the code region.

With Alt Default

                  Using Press ALT Key                               Default Selection

How to Place your reusable code into Toolbox in Visual Studio?

This is very important and small tips for all VS users. Sometimes we need a small piece of code in many places of our application or in some different application. What we do? We just copy the code from one page and paste it to the destination page.

Visual Studio having a great feature, that you can place your code snippet inside the toolbox. For that you need to just select the code snippet and drag the selected snippet on to the general Tab.CodeSnippet

You can rename the selected snippet, by just right clicking on snippet and click on Rename.

RenameCodeSnippet

Now, you can use it anywhere in your application or in any VS Application by just drag and drop of the selected snippet.

Hope this will help you in future from rewrite of code.

How to Freeze GridView Header While Scrolling ?

This is very common problem in Web development that we need to freeze the GridView header at the time of scrolling, Here is one simple tips:
Step 1 : Create a CSS class as following

.HeaderFreez
{
position:relative ;
top:expression(this.offsetParent.scrollTop);
z-index: 10;
}

Step 2 Set Gridview’s HeaderStyle CssClass as follows
CssClass="HeaderFreez"
That’s all. Some times we need also maintain the scroll positions while selecting any data from GridView, and quite difficult to maintain the position while we are using AJAX, I have written a complete article on that, hope this will help Maintain GridView Scroll Position inside updatepanel

Cheers!!
Abhijit

171 comments

  1. Hi Abhijit,
    Great article you are writing. Please help developmenet community much by writing various articles.

    Keep it up.
    Cheers!
    Rakesh Yadav

    Like

  2. When i make a postback by textchange , the header of the grid move to the right of the page , and the layout of the datagrid changed to be wrong

    Do you have any solution

    Like

  3. Hi Dude!

    Iam a first time visitor of ur site.. its very nice.. and simple.. u just simply decorate your website with ur certifications which is very interesting !

    cheers

    Like

    1. Hi Abhijit,

      I have seen your article and your your Website. I am realy impressed you. I am beginner of .Net technology. Please suggest me best book for ASP.net.

      Regards & Thanks

      Manmohan

      Like

      1. Thanks mate. Regarding book you can go with Aprees ASP.NET Book or may be from Wrox publication. Also try to read from online articles.
        Let me know if you have any concern.

        Like

  4. Hai Abhi.
    compliments of the day.
    First of all we not from soft/hard fileds.my comapny having website last one year.i want to known how many pople viewed(visted) my company website.
    we want to keep comapny website in google search.

    Kindly advice

    Regards
    Kranthi

    Like

  5. Plz tell me the way to store images(jpeg) into the sql server 2000 and how to retrieve them.

    You have made a nice website of yours.

    Like

  6. thanks for your wonderful tips. I am the regular reader of your articles. I have read your article ” Beginner’s Guide to ASP.NET Application Folder”. please send one article only on App_code like Session.

    Like

    1. Nice to know you liked my article. Regarding App_code article, there is noting much to write like session. I am really out of time… still Two article is in progress. hope to publishef soon.

      Like

  7. Hi Abhijit,

    i am really pleased with ur articles.this is the first time i am visiting ur site.i want to write microsoft certification exams.but i dont know which one to write as a fresher.could u tell me the exam name and number.
    thanks

    Like

  8. Hi Abhijit

    I am visiting your site first time. It’s really good to read such articles. Keep it up. Please mail me names of book you reffered before and reffering now related to ASP.NET,AJAX,C#,VB,SQL SERVER

    Like

  9. Hi dude,
    I read your article about ViewState.
    It is fantastic. It is first time I am visiting your article & it seems to me that I will explore all your your articles on the site. Please response my Q’s If I ask to u.
    Thanking u.

    Like

  10. Hello Boss,
    How are you? I have seen you article on codeproject on session it is really nice.

    I impressed and go through your profile looks gr8 yaar 🙂 keep it up. My self ashish amodia, done MCA working as software developer at surat. Nice to see you.

    This is my mail Id amodia.a.s@gmail.com.
    I am also on orkut “Ashish Amoida”.

    It think its good to be friends we can share many things.

    Ok than c u bbye
    whts ur ID ???

    Like

  11. Hi Abhi,
    It’s pleasure to talk with u.
    I have a problem just like…
    I want to zoom+ a picture in ASP.NET on OnMouseover event. How it will get effect? I asked this question but one suggested to use “Jquery”. I m not familiar with “Jquery” but ASP.NET AJAX.

    Like

  12. Thanx dude,
    I m done with ur reply…Ohh..Sorry,I explored ur answers & You never replies,instead,it is always solution for the query…for me & same to all..
    Thank u again.

    Like

  13. Hi i am begnier i asp.net and now days i am faceing some problem that is “Unabele to connect asp.net server” at the time of website run plz help me
    more evere ur realy cooooool

    Like

  14. hello sir..

    i am developing 3-tier web application in asp.net with c#..

    right now in doubt regarding where to write code for session ,cookie management?

    will you give me example showing this clearly?

    thank you.

    Like

  15. hi abhijit jana
    i am completed my BCA from mcu bhopal.i am developing web application in asp.net with c#..
    place give me tips.

    Like

  16. hi abhijit jana

    I have completed by B.tech in cs stream. I am trying to develope a website in asp.net using c# i would like to know how i can add the session for each user and how to destroy it when user signout and the page must not be restored if he press the back button in the browser after signingout.I would be very thankful if i can get some sort of help from you so that i can learn something.
    Thanking you

    Like

  17. Hi Abhijit Sir,
    This is ashish shukla from lucknow.Sir i have completed my mca from uptu and working in a lucknow based company.Sir i have visited ur site since last few months,i really inspired by you and your articles.Sir please guide me how can i explore my knowledge in field of .net.
    I will be very thankfull to u.

    Like

    1. Hi Ashish,
      Nice to know you liked my article and blog . Great man !!

      I have sent a mail to your gmail id from my personal id. Let me know if you need any help from me.

      Thanks again!

      Like

  18. Hi Abhijit,

    Is it possible to write a code on selected index change event in javascript that will populate another ddl depending on selected value, hence to avoid server trip.

    Thanx..

    Like

  19. Hi Abhijit,

    I have seen your article and your your Website. I am realy impressed you.
    I read your article about ViewState. It is fantastic.

    keep it up !!!!!!!!!!!!!

    Regards & Thanks

    UDDHAV GARKAL
    (FACULTY)
    {NIIT}

    Like

  20. Hi Abhijit Sir,
    This is Abhijeet Jadhav from Pune. I have completed my mcs from pune university and working in a pune based company.Sir i have read ur articles,i really inspired by you.
    Sir please Can you suggest some guidelines how to develop dot net skills.
    I will be very thankful to u.

    Like

  21. Great Article!

    If I could write like this I would be well chuffed 😉

    The more I read articles of such quality as this (which is rare), the more I think there might be a future for the Web. Keep it up, as it were.

    Like

  22. HI Abhijit,

    I have asekd abt ActivDirectory. For that you gave me one link. I missed that link. Could you plz give me that link again.

    Thanks & Regards
    Mohan Dass.

    Like

  23. Hi Abhijith,

    First of all congrats to wons a Sony VAIO® Notebook for ZoomSliderVSX article.I also follow the codeproject and dotnet fundas.Your article are wonderful and very use ful.Keep going.

    Raghav

    Like

  24. Your articles have been so inspiring and helpful. Keep it up!

    I have tried (and still trying hard) so many times to configure IIS on windows server 2003 standard edition. It seems not to be working despite reference to tens of articles, how-tos and walkthroughs. Can you please give me SURE guides on how to configure IIS on Windows server 2003. I really want to run my ASP.Net website on my Local Network first before hosting them on website. I already have compiled ASP.Net projects I want to setup.

    Thanks for your help

    Like

      1. I have read this before; but couldn’t get it to work. But I will go through it again; and keep you posted on the progress. Thank you so much for being of help

        Like

      2. I got this error when i try to browse my website from the IIS Manager:

        The page cannot be displayed
        You have attempted to execute a CGI, ISAPI, or other executable program from a directory that does not allow programs to be executed.
        ——————————————————————————–

        Please try the following:

        Contact the Web site administrator if you believe this directory should allow execute access.
        HTTP Error 403.1 – Forbidden: Execute access is denied.
        Internet Information Services (IIS)

        ——————————————————————————–

        Like

        1. In Virtual Directory property window, you have a dropdown box “Execute permission”, what is the value of that ?

          And you can register iis using asp.net using aspnet_regiis command.

          Thanks

          Like

  25. I just noticed you used php on this website when i submitted this comment. Why? despite your wealth of asp.net knowledge. Is it that php is better than aspx in certain instances?. Kindly enlighten me.

    Like

  26. Thank you for the real instant response

    1. “Execute permission”= None. But when i change this to either of the 2 0ther options; i get the message that ‘The Web Application is not available’

    2. On which directory in the command prompt am i to use the ‘aspnet_regiis’ command.

    Like

    1. Hi,

      Check the security Tab of your Folder and check what permission do you have.
      “Execute permission” should be chnaged script and executable.

      For Ruuning aspnet_regiis form the the Framework Directory. Ideally it should like C:\Windows\Framework\Version\V 2. XXXX\ aspnet_regiis.exe

      Goto Command prompt > navigate to that folder > Run > aspnet_regiis – i

      After that, Goto IIS > Right Click on Virtual Dir > Goto ASP.NET Tab > Set the proper version
      Let me know if it not resolved.

      Like

      1. Thank you for for your help, i was able to successfully register aspnet with my iis using the instruction you provided.

        Also i changed the execute permission property to ‘Script and Executable’
        i also changed the version of ASP.Net to 2.0.50727

        But when i browse the site from iis manager, i got the following error message:

        Server Application Unavailable
        The web application you are attempting to access on this web server is currently unavailable. Please hit the “Refresh” button in your web browser to retry your request.

        Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.

        What do i do to resolve this? Thanks

        Like

        1. Did you create the aplication form : Right Click Virtual Directory > Goto Virtual Directory Tab > Goto Application Setting Section > Click on Create Button.

          You also need to give aspnet user access to that virtual directory.

          Then Reset your IIS.

          You are ready to go..

          Let me know if you need any more help.

          Like

  27. Thank you. The error ‘Server Application Unavailable’ is still there even after i did all you said i should do except ‘give aspnet user access to that virtual directory’

    So, how do i ‘give aspnet user access to that virtual directory’

    Like

    1. Hi, Sorry for late response. There should not be any error. I would suggest you to delete the virtual directory once and create fresh one. Set all the properties properly. Hope this will resolve your issue.

      And regarding how to give user access, I would recomand you to go through my IIS article.

      Thanks !

      Like

  28. Friend Abhijit ,

    Nice tips also very useful. thanks alot friend. i wanna touch with you.

    Thanks & Regards
    vidyasankar N

    Like

  29. Hi Abhijit,
    Wonderful articles thanks for this.
    This is PradeepKumar
    I am using VS 2003 and i have made changes in one file and builded the application.
    The problem is it is not executing the new code which i have written, can you please help me out to sort this.
    For eg: see below code

    Existing code ———————————– 1

    New code i have written here ——————–2

    When i try to set break point and execute it directly goes to next line of 2 in above it is not executing the new code.
    I have done all the posibilites, i have deleted pdb even obj and bin folders and regenarated all.
    I have even created new solution and tried adding new project and added the files even then problem persists.

    Please help me out.

    Thanks
    PradeepKumar Gnanavel.

    Like

  30. Hi Abhijit,

    I am working on development of an online exam application, can u plz suggest me the way to do it using database? I have created table for storing questions and answers, I want to print the question and its options on the page. Question will be a label, and options will be in RadioButtonList.
    There will be multiple questions on the page.
    Table structure is QuestId, QuestName, option1, option2, option3, option4, CorrecrtAnswer..

    Please do help me..

    Thanx in advance..

    Like

  31. greetings sir

    I had just gone through you website for the first time, i find it awesome…you are doing a great job sir….keep provide us the best articles so that we can can get maximum out of it and every student like me will find easy to work with the visual studio. I really appreciate you.

    Thank you

    Salil Kumar Gupta

    Like

  32. Dear Abhijit Jana,
    I am Arun.Potti studying MCA final year. I recently visited u r site and read some articles in CodeProject.com site. Those are fantastic. I understand the topics very clearly and easily. I appreciate u for having great articles.

    Thank u,
    Arun.Potti

    Like

  33. Hi Abhijit, nice site. i am keen to be aps.net developer, plz guide me that which book should i start and how can i come proffessional web developer. plz share your kind suggestions and if possible mail me .

    Thanks

    Like

  34. Hi Abhijit,
    I read your articles and very happy to learn and explore new things. Please keep writing because it would be very informative for someone(like me).
    I am facing a problem related Crystal Report.My problem is “Crystal Report Print After Deployment Without Showing Preview”.

    Please help me

    Like

  35. Hai Abijit

    I would like to join for Microsoft Research Internship program. I need to know the requirements and your tips for that…

    Waiting for replay…

    Like

  36. Hi Abhijit,

    Very Good Artical regarding Diff between web farm and webgarder with design layout.

    Keep it up for next article

    Like

  37. First I wud like to say u r SUPERB BOSS , Hats OFF To u.

    Second i read ur article Beginner’s Guide: How IIS Process ASP.NET Request.
    I wud like u to add more about HttpModule and HttpHandler in this articles.
    What i understood that HttpHandler just generates the output but how ?
    I wud glad u add this also

    Like

  38. Hello Abhijit I am also from Kolkata….
    I m new(6 mths) to dot net so want to take some certification. Please help me by guiding me as which one to give first …. its name and how to prepare for it so that I can crack it in the first time only.
    I will be waiting for ur reply.
    Thanx,
    Raj.

    Like

  39. Hi Abhijit Sir,
    Hats off to Ur support u providing to every one.
    This is Suhel khan from Bhopal. .Sir i have read Ur articles,i really inspired by you.
    and will u let me know regarding the .net certifications for the fresher,and pls suggest me best to develop my skill,i am basically interested in asp.net.
    Thanks in advance

    Like

  40. Hii Sir….

    I’m new in asp.net, just 8month experience in asp.net.Sir I read your articles over asp.net.
    Sir I have question (what is boxing and unboxing?) Sir can u please help me in this mater…..

    Thanks.

    Like

  41. i have seen lots of video in which presenter drag code from toolbox . At that time i was thinking how it is possible.But now i know. 🙂

    Thanks Abhijit

    Like

  42. hiii sir

    i am new to your website but i am really impressed to see your contribution in making thing very easy to learn and understandable. sir, can u please tell me how to show friend list along with their profile images (that i have stored as path in sql server) in grid view in asp.net

    Like

  43. HI ABHI as i saw ur website then i get many idea how to do my best…
    sir i ve 1 prob:–>
    i want to access the webcam through the coding using C# 2010 i m not getting any idea plz if u ve any idea plz share with me..through my e-mail id (kuldeepn20@gmail.com)…
    i m very thankfull to U…

    Like

  44. Hi,

    I Need help with a command or script using which i can get ASP.net version of all websites listed under IIS manager ( version 6 ).

    I need to get it for hundreds of servers, so need some batch script to get that details and export to a file on my desktop. Trying to find a way by which we can get these info from remote servers ….please help

    Need info to be displayed in the order: Server Name , Website Name , ASP.NET version
    ( exported to a excel sheet or notepad )

    Like

  45. Hi Sir,
    Well done for your contribution to the society in .NET platform.
    Actually I have one problem. I am kinect using Kinect SDK beta 1.0 SDK. I have one MainWindow.xaml and its code file. I want to open serial port only a single time but when I put it in Mainwindow.xaml.cs file I found that (using debugger ) code is executed several times as image is regenerating continously as I am showing image of the camera of Kinect. So where should I put sp.Open() where sp is Serial Port object so that it will be executed only once in the program i.e. at the beginning of the program.

    Thanks in Advance.

    Like

  46. Hi ahhi,
    Your articles are very useful for me and many people.
    Continue your good job and many thanks for share your valuable knowledge.

    Regards

    Like

  47. hi abhijit this is hari.present i am under training in.net.but basicallly i am from non cse brach.i feel difficult in programming.give a suggestion please

    Like

    1. Dear Hari, It is absolutely fine coming from non CSE background and joining in IT and having started .NET / programming language. For that to start with I would recommend to have some starter book .NET and C# basic programming. Also read some book which talks about programming language understanding, flow charts , etc.
      Then have some practice to read some blog, articles over internet based on your study from book. Then do some hands on by your own.

      flow some site like https://www.khanacademy.org/computing/computer-programming

      Feel free to reach out to me if you need additional help

      Like

  48. Hello Abhijit,

    Last few years I did not see any of your new article in your Site as well as in Code project… What happen!!! Its really disappointing as I am a grt fan of u r articles

    Like

Leave a comment