How To Shrink Database File Using DBCC Shrinkfile



TODO:

Have you ever wanted to shrink a database or log using DBCC Shrinkfile?

 

SOLUTION:

DBCC SHRINKFILE(DataOrLogFile, 1)

 

NOTES:

There are no notes on this topic

How To Add OnBlur Or OnFocus To A TextBox In The Codebehind



TODO:

Have you ever wanted to add the onblur or onfocus event to a TextBox in the Codebehind?


SOLUTION:

//add focus
myTextbox.Attributes.Add("onfocus", "MyJavascriptFocusFunction(this);");

//add blur
myTextbox.Attributes.Add("onblur", "MyJavascriptBlurFunction(this);");

 

NOTES:

There are no notes on this topic.

How To Call Click Event On A Button When Retern Is Pressed On A TextField In The Codebehind



TODO:

Have you ever wanted to "click" a button when someone presses return on a Textbox?  The code below, goes in the codebehind of your aspx file.

 

SOLUTION:

myTextBox.Attributes.Add("onkeypress", "if(event.keyCode==13) {document.getElementById('" + myButton.ClientID + "').click(); return false;}");

 

NOTES:

There are no notes on this topic.

Google Search Widget For BlogEngine.Net



TODO:

Do you want to have a google search widget for BlogEngine.Net?  

 

SOLUTION:

Download the GoogleSearch.rar file below.  Create a directory for it in the widgets folder which is located under the root.  Unzip all files to that folder.  Now when you look at your page, you can add the widget to your pages.

 

NOTES:

There are no notes on this topic

GoogleSearch.rar (3.05 kb)

How To Fix "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS"



TODO:

You open a website in Visual Studio, and get the dreaded "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS" error message.

 

SOLUTION:

1.  Make sure you opened the site and not the parent folder.

2.  In my case, I created a folder called "backup", and copied my entire site to it.  Therefore, when I opened the site, that folder was loaded, and it too had a Web.Config file in it (since this folder contained a complete site backup).  Simple remove that Web.Config and you will be set.

 

example showing my problematic folder structure:

root

Web.Config

site folder 1

site folder 2

backup

Web.Config

site folder 1

site folder 2

 

NOTES:

The presence of the backup folder in red is the culprit.  It contained a backup copy of the root web.config, which contained entries only allowed in the root level Web.Config.

How To Programmatically And Recursively Clear All Form Controls



TODO:

Have you ever wanted to recursively clear a screen, without the need to manually clear each control?  This can be extremely helpful when it comes to large forms.

 

SOLUTION:

public void ClearControls(Control InControl, bool ClearLists, bool SetRadioButtonDefaultToFirstItem, bool SetDropDownDefaultToFirstItem)
{
    foreach (Control control in InControl.Controls)
    {
        //if its a check box, just clear the text
        if (control is CftcTextBox)
        {
            ((CftcTextBox)control).Text = string.Empty;
        }
        else if (control is CheckBoxList)
        {
            //deselect each check box item.
            foreach (System.Web.UI.WebControls.ListItem item in ((CheckBoxList)control).Items)
            {
                item.Selected = false;
            }
        }
        else if (control is DropDownList)
        {
            //deselect all items
            foreach (System.Web.UI.WebControls.ListItem item in ((DropDownList)control).Items)
            {
                item.Selected = false;
            }

            //if we choose, we now select the first item in list
            if (SetDropDownDefaultToFirstItem)
            {
                if(((DropDownList)control).Items.Count > 0)
                {
                    ((DropDownList)control).SelectedIndex = 0;
                }
            }
        }
        else if (control is System.Web.UI.WebControls.ListBox)
        {
            //if we clear lists, then remove all items.  otherwise, just deselect all list items.
            if (ClearLists)
            {
                ((System.Web.UI.WebControls.ListBox)control).Items.Clear();
            }
            else
            {
                foreach (System.Web.UI.WebControls.ListItem item in ((System.Web.UI.WebControls.ListBox)control).Items)
                {
                    item.Selected = false;
                }
            }
        }
        else if (control is RadioButtonList)
        {
            //default to the first item, if we choose to
            if (SetRadioButtonDefaultToFirstItem)
            {
                if (((RadioButtonList)control).Items.Count > 0)
                {
                    ((RadioButtonList)control).Items[0].Selected = true;
                }
            }
        }

        //now call recursively
        if (control.HasControls())
            ClearControls(control, ClearLists, SetRadioButtonDefaultToFirstItem, SetDropDownDefaultToFirstItem);
    }
}

 

NOTES:

There are no notes on this topic.

How To Filter A Tablix With An OR Condition In SQL Server Report Builder



TODO:

Have you ever wanted to filter a tablix using an OR clause.  The interface is a little confusing, but the steps below will accomplish this.

 

SOLUTION:

1.  Open Tablix Properties

2.  Add Filter

3.  Set Filter Expression: =(Fields!MyTagName.Value = "value1" OR Fields!MyTagName.Value = "value2" OR Fields!MyTagName.Value = "value3")

4.  Set Filter Expression Type: Boolean

5.  Set Filter Operator to '='

6.  Set Filter Value = 'True'

 

That should do it.

 

NOTES:

There are no notes on this topic.

How To Fix A Database Stuck In [Recovery Pending] Status In SQL Server Management Studio



TODO:

SQL Server Management Studio reports a database in "Recovery Pending" status. 

 

SOLUTION:

use master

ALTER DATABASE YourDatabase SET OFFLINE WITH ROLLBACK IMMEDIATE
ALTER DATABASE YourDatabase SET ONLINE WITH ROLLBACK IMMEDIATE


NOTES:

There are no notes on this topic.

How To Fix "The maximum string content length quota (8192) has been exceeded while reading XML data." error when calling WCF



TODO:

How to fix the error "The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader"

 

SOLUTION:

1.  Open your web.config. 

2.  Look for the binding entry for your Service. (<basicHttpBinding><binding name=...)

3.  Replace the value in the attribute maxStringContentLength="8192" with "2147483647"

 

NOTES:

There are no notes on this topic.

How To Enter BIOS Setup in PowerSpec B631 Running American MegaTrends BIOS



TODO:

Have you ever wanted to enter BIOS on a PowerSpec B631, but you do not get the splash screen telling you which key to press?

 

SOLUTION:

1.  Power down your machine

2.  Unplug your machine for 30 seconds, then plug back in.

3.  Power on machine, and press DEL key repeatedly until you get to BIOS Setup.

 

NOTES:

There are no notes on this topic.