Friday, March 26, 2010

How to Remove and Hide Blogger NavBar (Top Navigation Bar)

I find this Navigation bar on top of the blog useless for me and readers of the blog.

Unfortunately it’s not possible to hide this NavBar using blogger settings.   But you can do this manually editing Html of the page and adding needed CSS class there.  Here are the instructions:

  • Login to Blogger.
  • On the Blogger Dashboard, click on the Layout link of the blog.

    image

  • The Edit HTML page under Layout tab should be loaded. If not, go to the tab.
  • Search for the following line of code:

    </style>

    Then, add the following line of code before that line:

    #navbar-iframe{ display: none !important; }

    The Blogger Classic Template uses iframe to load the NavBar, and styles it with ID named navbar-iframe. The name actually also works for new Blogger Widget Template too.

  • Register for Visual Studio 2010 Beta Exams

    You are invited to take part in one or more beta exams for Visual Studio 2010 and the Microsoft .NET Framework 4.

    If you pass one of the beta exams, the exam credit will be added to your transcript and you will not need to take the exam in its released form. The 71-xxx identifier is used for registering for beta versions of MCP exams, when the exam is released in its final form the 70-xxx identifier is used for registration.
    By participating in beta exams, you have the opportunity to provide the Microsoft Certification program with feedback about exam content, which is integral to development of exams in their released version. We depend on the contributions of experienced IT professionals and developers as we continually improve exam content and maintain the value of Microsoft certifications. The following exams are a part of this beta offering.

    Exam 71-511, TS: Windows Applications Development with Microsoft .NET Framework 4

    Exam 71-515, TS: Web Applications Development with Microsoft .NET Framework 4

    Exam 71-513: TS: Windows Communication Foundation Development with Microsoft .NET Framework 4

    Exam 71-516: TS: Accessing Data with Microsoft .NET Framework 4

    Exam 71-518: Pro: Designing and Developing Windows Applications Using Microsoft .NET Framework 4

    Exam 71-519: Pro: Designing and Developing Web Applications Using Microsoft .NET Framework 4


    Availability

    Registration begins: March 17, 2010

    Beta exam period runs: April 5, 2010 – April 30, 2010

    Receiving this invitation does not guarantee you a seat in the beta; we recommend that you register as soon as registration opens. Beta exams have limited availability and are operated under a first-come-first-served basis. Once all beta slots are filled, no additional seats will be offered. If you register, please ensure you are committed to attend.

    Testing is held at Prometric testing centers worldwide, although this exam may not be available in all countries (see Regional Restrictions). All testing centers will have the capability to offer this exam in its live version.

    Regional Restrictions: India, Pakistan, China


    Registration Information

    You must register at least 24 hours prior to taking the exam.
    Please use the following promotional codes when registering for your chosen exam(s):

    Exam Number Beta Code
    71-511 511BC
    71-515 515AA
    71-513 513CD
    71-516 516B1
    71-518 518PE
    71-519 519ZS

    To register in North America, please call:

    •Prometric: (800) 755-EXAM (800-755-3926)

    Outside the U.S./Canada, please contact:

    •Prometric: http://www.register.prometric.com/ClientInformation.asp


    Test Information and Support

    You are invited to take this beta exam at no charge.
    You will be given four hours to complete the beta exam. Please plan accordingly.

    Find exam preparation information:

    Exam 70-511, TS: Windows Applications Development with Microsoft .NET Framework 4

    Exam 70-515, TS: Web Applications Development with Microsoft .NET Framework 4

    Exam 70-513: TS: Windows Communication Foundation Development with Microsoft .NET Framework 4

    Exam 70-516: TS: Accessing Data with Microsoft .NET Framework 4

    Exam 70-518: Pro: Designing and Developing Windows Applications Using Microsoft .NET Framework 4

    Exam 70-519: Pro: Designing and Developing Web Applications Using Microsoft .NET Framework 4


    Frequently Asked Questions

    For Microsoft Certified Professional (MCP) help and information, you may log in to the MCP Web site at http://www.microsoft.com/learning/mcp/

    or contact your Regional Service Center:

    http://www.microsoft.com/learning/support/worldsites.asp.

    What is a beta exam?

    Where can I learn more about the registration process?

    Where can I learn more about the beta exam invitation process?

    Where can I learn more about the new structure of Microsoft Certification?

    Who do I contact for help with this beta exam or other MCP questions?

    Tuesday, March 9, 2010

    SQL 2008 Management Tools: Can't save changes that require Recreation of Database

     

    New stupid default setting in SQL Server's Management Tools: When you design a table in a database and then try to make a change to a table structure that requires the table to be recreated, the management tools will not allow you to save the changes. Instead you'll be greeted by this friendly dialog:

    PreventSave2

    Notice that there's no option to save the changes - it's a hard rule that is applied upon saving and you can get past this other than back out of the dialog.

    My first thought here is "Crap! Now what?" and off I go searching for an option to turn this off. Eventually I find a solution after a quick search online. As it turns out it's just an annoying configuration default setting that can be easily changed, but if you're like me and you spend a while searching around the Management Tools and finding nothing initially, I ended up eventually backing out of my initial database changes and losing a bit of work in the process. It wasn't until a bit later that I found the setting to change.

    Hopefully you'll find this entry before you back out of database changes - you can get out of the above dialog, make the settings change and then still go ahead and save changes to your database.

    The fix is: Go to Tools | Options | Designers | Tables and Designers and uncheck the Prevent Saving Changes that require table re-creation option:

    PreventSavingChanges

    and that does the trick.

    This is a pretty harsh change IMHO. While I think it's a good idea that the tools now detect table recreation changes and can notify you, I think the better option by far would have been to pop up that initial dialog with a warning message AND provide an option on the buttons to either go forward or abort. Instead this arcane switch is going to cause some pause for most people familiar with the old tool behavior. It's not like this option is easy to find - I looked in the database options before I finally found it in the global tool options.

    As it is, reverting back to the 'old' behavior now doesn't let you know that a table recreate is required either, so the behavior now is the same as was with the old tools. Here Microsoft added some useful functionality and then UI fails to expose it intelligently...

    Source

    Tuesday, January 5, 2010

    Enable the Secret "How-To Geek" Mode in Windows 7

    We haven’t told anybody before, but Windows has a hidden “How-To Geek Mode” that you can enable which gives you access to every Control Panel tool on a single page—and we’ve documented the secret method for you here.

    Update: Do not use this on Vista. If you did, you can use Ctrl+Shift+Esc to start task manager, File \ Run and open a command prompt with cmd.exe, and then use the rmdir command to get rid of the folder.

    To activate the secret How-To Geek mode, right-click on the desktop, choose New –> Folder, and then give it this name:

    How-To Geek.{ED7BA470-8E54-465E-825C-99712043E01C}

    image

    Once you’ve done so, you’ll have activated the secret mode, and the icon will change…

    image

    Double-click on the icon, and now you can use the How-To Geek mode, which lists out every single Control Panel tool on a single page.

    image

    At this point you might notice why this is a stupid geek trick—it’s much easier to use the default Control Panel than navigating through a massive list, and anybody that really calls themselves a geek will be using the Start Menu or Control Panel search box anyway.

    In case you were wondering, this is the same as that silly “God Mode” trick that everybody else is writing about. For more on why it’s pointless, see Ed Bott’s post on the subject.

    Alright, So It’s Not Really a Secret How-To Geek Mode

    Sadly, this is nothing more than a stupid geek trick using a technique that isn’t widely known—Windows uses GUIDs (Globally Unique Identifiers) behind the scenes for every single object, component, etc. And when you create a new folder with an extension that is a GUID recognized by Windows, it’s going to launch whatever is listed in the registry for that GUID.

    You can see for yourself by heading into regedit.exe and searching for {ED7BA470-8E54-465E-825C-99712043E01C} under the HKCR \ CLSID section. You’ll see on the right-hand pane that it’s the “All Tasks” view of the Control Panel, which you can’t normally see from the UI.

    image

    You can use this same technique for other Windows objects by doing some digging around in the registry… for instance, if you were to search under HKCR \ CLSID for “Recycle Bin”, you’d eventually come across the right key—the one on the left-hand side here:

    image

    So if you created a folder with the name “The Geek Knows Deleted Files.{645FF040-5081-101B-9F08-00AA002F954E}”, you’d end up with this icon, clearly from the Recycle Bin.

    image

    And it’s even a fully functional Recycle Bin… just right-click and you’ll see the menu:

    image

    So here’s the quick list of the ones I felt like digging up, but I’m sure there’s more things you can launch if you really felt like it.

    Recycle Bin: {645FF040-5081-101B-9F08-00AA002F954E}

    My Computer: {20D04FE0-3AEA-1069-A2D8-08002B30309D}

    Network Connections: {7007ACC7-3202-11D1-AAD2-00805FC1270E}

    User Accounts: {60632754-c523-4b62-b45c-4172da012619}

    Libraries: {031E4825-7B94-4dc3-B131-E946B44C8DD5}

    To use any of them, simply create a new folder with the syntax AnyTextHere.{GUID}

    Create Shortcuts to GUIDs

    Since the GUID points to a Windows object launched by Windows Explorer, you can also create shortcuts and launch them directly from explorer.exe instead of creating the folder. For instance, if you wanted to create a shortcut to My Computer, you could paste in the following as the location for a new shortcut:

    explorer ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

    image

    And just like that, you’d have a shortcut to My Computer, which you can customize with a different icon, and a shortcut key if you so choose.

    image

    Yeah, it’s a stupid geek trick, but it’s always fun to learn new things.

    Note: The Control Panel’s All Items hack and the Libraries hack will probably only work in Windows 7. The others should work in any version of Windows.

    Source

    Thursday, November 5, 2009

    How to use standard FileUpload in AJAX-enabled web applications

     

    I would like to note that this article is not about the ability to upload files to the server without the postback. There are a lot of articles on this topic, just type "AJAX FileUpload" in any search engine and you'll get many examples. However with AJAX they actually have little in common, because the XMLHttpRequest does not support asynchronous uploading of files to the server, they are rather a variety of imitations, for example, using hidden IFRAME element. Nevertheless I want to emphasize that the article is not about that but about the standard FileUpload control.

    There are two problems you might encounter when using it on UpdatePanel.

    Problem 1
    If the postback is caused by a control which lies on the UpdatePanel, the FileUpload is always empty when it come to the server, regardless whether a file has been selected or not.
    Example:

    <asp:UpdatePanel ID="UpdatePanel1" runat=server>
    <ContentTemplate>
    <asp:FileUpload ID="FileUpload1" runat=server />
    <asp:Button ID="btnUpload" runat=server Text="Upload" OnClick="btnUpload_Click"/>
    </ContentTemplate>
    </asp:UpdatePanel>

    Solution


    As XMLHttpRequest does not allow to send files asynchronously, they have to be submitted in a common manner. This problem is well described around, it is solved by registration of the control that has to submit the form as a postback trigger (in the above example it is btnUpload button).

    <asp:UpdatePanel ID="UpdatePanel1" runat=server>
    <ContentTemplate>
    <asp:FileUpload ID="FileUpload1" runat=server />
    <asp:Button ID="btnUpload" runat=server Text="Upload 2" OnClick="btnUpload_Click"/>
    </ContentTemplate>
    <Triggers>
    <asp:PostBackTrigger ControlID="btnUpload" />
    </Triggers>
    </asp:UpdatePanel>


    Problem 2


    FileUpload does not work if it is loaded not on the initial page load but appears only after asynchronous update of the page part.


    Example (pnlUpload panel is invisible in the beginning and is shown after clicking on btnShowFileUpload button):



    <asp:UpdatePanel ID="UpdatePanel1" runat=server>
    <ContentTemplate>
    <asp:Button ID="btnShowFileUpload" runat=server Text="Show File Upload" OnClick="btnShowFileUpload_Click"/>
    <asp:Panel ID="pnlUpload" runat=server Visible="False">
    <asp:FileUpload ID="FileUpload1" runat=server />
    <asp:Button ID="btnUpload" runat=server Text="Upload" OnClick="btnUpload_Click"/>
    </asp:Panel>
    </ContentTemplate>
    <Triggers>
    <asp:PostBackTrigger ControlID="btnUpload" />
    </Triggers>
    </asp:UpdatePanel>

    .......................

    protected void btnShowFileUpload_Click(object sender, EventArgs e)
    {
    pnlUpload.Visible = true;
    }

    Solution


    The problem is caused by the requirement that for the normal work of FileUpload the form should have enctype="multipart/form-data". Usually, it is set in overriden OnPreRender method of FileUpload control.

    protected internal override void OnPreRender(EventArgs e)
    {
    base.OnPreRender(e);
    HtmlForm form = this.Page.Form;
    if ((form != null) && (form.Enctype.Length == 0))
    {
    form.Enctype = "multipart/form-data";
    }
    }

    Although during asynchronous postback this code is also executed but the form is not updated. That is why it is required to set the form content type explicitly during the first page load, for example, in the Page_Load event handler of the page or a control where FileUpload is placed.

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    this.Page.Form.Enctype = "multipart/form-data";
    }

    In case if this task is repeated in a few places you may do a simple control derived from FileUpload with overriden OnLoad method and use it.

    public class CustomFileUpload : FileUpload
    {
    protected override void OnLoad(EventArgs e)
    {
    base.OnLoad(e);

    if (!Page.IsPostBack)
    this.Page.Form.Enctype = "multipart/form-data";
    }
    }


    Source article

    Monday, October 19, 2009

    Async FileUpload control for AJAX pages

    With the new release of Ajax Control Toolkit (v 3.0.30930) released specifically for .NET 3.5 SP1 (with Visual Studio 2008 SP1), there are couple of new controls.  One of them is the AsyncFileUpload control.

    Thanks to the codeplex community which keeps getting better and better with time, the Ajax Control Toolkit has grown into one of our largest community contributed controls for ASP.NET with about 43 controls that help in accomplishing rich user experiences in ASP.NET Websites.

    The AsyncFileUpload is one simple way of accomplishing what I had written earlier using PostbackTrigger, the regular FileUpload control etc.,  To be able to use the AsyncFileUpload Control, you must have the latest version of AjaxControlToolkit installed.  The other pre-requisites are obviously NET 3.5 SP1 and Visual Studio 2008 SP1 (or the free Visual Web Developer Express Edition)

    You can download the pre-requisites from the respective links above.  For downloading the AjaxControlToolkit, visit the CodePlex site.  You can download just the binary files or the Source files as well, if you require to modify.  The Script Files is useful if you want to just work with the client side scripts and not use the server controls.

    Once you have downloaded, you would need to add them to Visual Studio or VWD.

    1. Open Visual Studio and create a new webapplication or website.  Click to open the ToolBox

    2. Right Click and select “Add Tab”

    3. Provide a name say “Ajax Control Toolkit”

    4. Right Click the newly created tab and select “Choose Items”

    5. Click on the “Browse” button in the file dialog that opens and browse to the place where you downloaded the AjaxControlToolkit binaries

    6. Typically I would put them under C:\Program Files\Microsoft ASP.NET for consistency.

    7. Select the AjaxControlToolkit.dll and it would list all the new controls.

    8. Click “Ok” to add all the controls.

    9. You should now see under the newly created toolbox tab these controls.

    Once you are done with above, create a simple Default.aspx page in the application you created and drop the Script Manager control into your webform.  Next add an UpdatePanel with ContentTemplate.  Inside the ContentTemplate, add the AsyncFileUpload control into the webform as well as a button and 2 labels for the uploading and displaying messages respectively.  The markup looks something like below

    <form id="form1" runat="server">
       <div>
           <asp:ScriptManager ID="ScriptManager1" runat="server">
           </asp:ScriptManager>
           <asp:Image ID="img1" runat="server" ImageUrl="~/Images/spin2.png" />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
               <ContentTemplate>
                   <cc1:AsyncFileUpload ID="AsyncFileUpload1" runat="server" UploaderStyle="Modern" ThrobberID="img1"  />
           <br />
           <asp:Button ID="btnUpload" runat="server" Text="Upload"
               onclick="btnUpload_Click"   />
               <br />
               <asp:Label ID="Label1" runat="server" /> 
               <br />
               <br />
             </ContentTemplate>
           </asp:UpdatePanel>
           <br />
           <asp:Label ID="Label2" runat="server" />
       </div>
       </form>

    Also, you can see that I have added an asp:Image pointing to a spin image that is specified as the ID for ThrobberID in the AsyncFileUpload definition.  This is optional but nice to have since this would display the throbber icon while uploading takes time.

    Once you are done, you would need to define the action in the codebehind or in the script

    protected void Page_Load(object sender, EventArgs e)
          {
              Label2.Text = DateTime.Now.ToString();
          }

          protected void btnUpload_Click(object sender, EventArgs e)
          {
              AsyncFileUpload1.SaveAs(Server.MapPath((AsyncFileUpload1.FileName)));
              Label1.Text = "You uploaded " + AsyncFileUpload1.FileName;
          }

    Notice, the Label in the Page_Load event is just to indicate that indeed the operation happened asynchronously since the time that is displayed initially doesn’t change once you click on Upload button. 

    Try running this and you will find that the whole operation happens asynchronously without a full page reload.  Note that, you would need to still put the AsyncFileUpload control inside UpdatPanel for this behaviour.  Otherwise, it would behave like a regular postback control

    Wednesday, September 23, 2009

    How To: Change Instance Name Of SQL Server

    Recently I change the network name of one of my servers at work, because the box changed its job from a virtual machine server to the database server. Everything was going great until I decided to setup the server for replication and received the following error message.

    New Publication Wizard
    ——————————

    SQL Server replication requires the actual server name to make a connection to the server. Connections through a server alias, IP address, or any other alternate name are not supported. Specify the actual server name, ‘old_name’. (Replication.Utilities)

    ——————————
    OK
    ——————————

    So with a little hunting and SQL queries I found out that SQL Server doesn’t use the network name, it only excepts that as an alias. My SQL Server instance was still named “old_name”. I found that out by running these two queries:

    1. sp_helpserver
    2. select @@servername

    So in order to get the network name and the SQL Server instance name back in sync I had do these steps:

    1. Run this in Microsoft SQL Server Management Studio:
      1. sp_dropserver 'old_name'
      2. go
      3. sp_addserver 'new_name','local'
      4. go
    2. Restart SQL Server service. I prefer the command prompt for this, but you can just as easily do it in Services under the Control Panel
      net stop mssqlserver
      net start mssqlserver

    Then after that is done run this again, to make sure everything is changed:

    1. sp_helpserver
    2. select @@servername

    I don’t understand why SQL Server uses it’s own name versus the network name, might be due to the fact you can have multiple SQL Server instances install on one machine. It wasn’t too hard to change and probably stems from the days when SQL Server was known as Sybase, all in all, I learned something new and it only took 30 minutes of my day to fine the answer.

    From: Source