WordPress Limit on Length and/or Captions

•November 2, 2010 • Leave a Comment

I was having issues with WordPress page being blank after adding so many characters or captions.  It was easy to replicate time and time again.  I found a lot of people with the same issue and found a few lengthy solutions.  The one I choose was easy and it worked:


/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

/** Number of saved revisions; false = 0 */
define('WP_POST_REVISIONS', 10);

/** Trick for long posts */
ini_set('pcre.recursion_limit',20000000);
ini_set('pcre.backtrack_limit',10000000);

This code was added to the wp-config.php file, just after the DB_Collate entry. Once that was added, i refreshed the page it worked instantly after re-saving the page. Found this information on WordPress.org forums. The revision code was optional but will keep your database from growing, set the number of revisions you wish, i used 10.

Apache .htaccess Rules and Suggestions

•October 7, 2010 • Leave a Comment

I found these sites to be extremely helpful the other day!


htaccess ErrorDocument Examples
ErrorDocument Usage and Info

 

STATUS CODE LIST

401 Unauthorized
The request requires user authentication. The response MUST include a WWW-Authenticate header field (section 14.47) containing a challenge applicable to the requested resource. The client MAY repeat the request with a suitable Authorization header field (section 14.8). If the request already included Authorization credentials, then the 401 response indicates that authorization has been refused for those credentials. If the 401 response contains the same challenge as the prior response, and the user agent has already attempted authentication at least once, then the user SHOULD be presented the entity that was given in the response, since that entity might include relevant diagnostic information. HTTP access authentication is explained in “HTTP Authentication: Basic and Digest Access Authentication” [43].

403 Forbidden
The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. If the server does not wish to make this information available to the client, the status code 404 (Not Found) can be used instead.

404 Not Found
The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.

ErrorDocument 500 http://foo.example.com/cgi-bin/tester
ErrorDocument 404 /cgi-bin/bad_urls.pl
ErrorDocument 401 /subscription_info.html
ErrorDocument 403 “Sorry can’t allow you access today

Click here for the entire article!


htaccess rewrite, htaccess

 

An attempt to create a default skeleton .htaccess file with the very best apache htaccess examples… Updated semi-frequently based on detailed info from the Apache htaccess tutorial.

If you see any room for improvement, or if you can add something than go ahead and comment and I will definately give

http://www.askapache.com/htaccess/ultimate-htaccess-file-sample.html

Display CheckBoxList Selections

•July 26, 2010 • Leave a Comment

I was needing to do a CheckBoxList that would talley up the results, and show a graphic if nothing was checked, and hide the graphic if something was checked. I found the following somewhere and tweaked it a little:

  Sub Check(ByVal sender As Object, ByVal e As EventArgs)
        Dim i As Object

        Label4.Text = "<p>Selected Item(s):</p>"

        For i = 0 To txtCheckBox.Items.Count - 1

            If txtCheckBox.Items(i).Selected Then
                Image6.Visible = False
                Label4.Text += txtCheckBox.Items(i).Text + "<br />"
            ElseIf i = 0 Then
                Image6.Visible = True
            End If

        Next
    End Sub

     <asp:CheckBoxList ID="txtCheckBox" runat="server" TextAlign="left" AutoPostBack="True" OnSelectedIndexChanged="Check">
                        <asp:ListItem Text="One" />
                        <asp:ListItem Text="Two" />
                        <asp:ListItem Text="Three" />
                        <asp:ListItem Text="Four" />
       </asp:CheckBoxList>
                 
                    <asp:Label ID="Label4" runat="server" Text=""></asp:Label>
                    <asp:Image ID="Image6" runat="server" Visible="True" ImageUrl="img/ValidateWarning.png" />

AutoPostBack Refreshes to Top of Page

•July 23, 2010 • 1 Comment

When you have form elements that have AutoPostBack = TRUE, it usually will take the visitor back to the top of the page when executed.

To keep the page at it’s current spot add the following to the web.config:

<configuration>
<system.web>
<pages smartNavigation="true">
</system.web>
</configuration> 

This may be deprecated and a new way is available. Mainly works in IE and may cause problems when using javascript and dhtml scripts as they will not be rendered again while using smartnavigation according to another blog.

See SetFocus

Using Controls and Datasources from different ContentPlaceHolders

•July 18, 2010 • Leave a Comment

If you have a SqlDataSource control and a combobox on one contentplaceholder, and the gridview and datasource on another contentplaceholder, you will have problems associating the combobox to filter the gridview if you don’t use the example below to call the taget contentplaceholder and put a “$” between it and the controlID of the combobox…

 <asp:SqlDataSource       ... >
        <SelectParameters>
            <asp:ControlParameter ControlID="TheContentPlaceHolderID$TheControID" ... />
        </SelectParameters>
</asp:SqlDataSource>

ASP VB.NET CheckBox CheckedChanged Event

•July 17, 2010 • Leave a Comment

Here’s a small example of how to make a checkbox change a label property:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CheckBox ID="CheckBox1" runat="server" Text="Make the Label Change!" AutoPostBack="True" />
        <br />
        <br />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>

Here’s the VB Codebehind:


Partial Class Default2
    Inherits System.Web.UI.Page

    Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked = True Then
            Label1.ForeColor = Drawing.Color.Red
            Label1.Text = "This is True and Red"
        Else
            Label1.ForeColor = Drawing.Color.Green
            Label1.Text = "This is Else<br /> and Green"
        End If
    End Sub
End Class

Open Table in SQL Server 2008 Management Studio?

•July 2, 2010 • 2 Comments

This information was gathered after many searches to find out how to open a stupid table in table view instead of design view.  I found this information on some random which answered my questions:

When you start to use Sql Server Management Studio 2008 maybe the first change you’ll realize is Select Top 1000 Rows and Edit Top 200 Rows commands instead of Open Table command in 2005. If you want to change 200 and 1000 parametric you can change these parameters by Tools>Options>SQL Server Object Explorer> Commands.  When Commands is selected you can change the functionality of these commands by changing related values.  You can make these commands work for entire table by setting values to ‘zero’. 

To open the table like you once could: choose ‘Edit Top XXX Rows’ instead of ‘Select Top XXX Rows’.  This will open the table in the familiar “Table View”.

Palm to Face… I can’t believe I didn’t put that one together before searching all over the internet looking for that old familiar “Open Table” command…

Server 2008 hiberfil.sys exists…

•June 25, 2010 • Leave a Comment

Tidbit of information, I just ran out of space on a 2008 web server’s c:\ drive and found the hiberfil.sys file was 4gb… also had some log files to clear but found this information about the hiberfil.sys in a M$ forum somewhere. I executed the command on my server and it went away …


By default, in Windows Server 2008, the Hibernation feature is disabled (power options), yet the hiberfil.sys file is created. The hyberfil.sys file has the size of the servers’ physical memory, which can be many gigabytes. This is pointless because hibernation is not supposed to be used on production servers at all. A complete waste of resources. It may even be included in backups … (haven’t verified this)

At best, the hibernation feature may be used in Windows Server 2008 test/demo environments. Even there it shouldn’t be enabled by default and there shouldn’t be a hyberfil.sys file.

powercfg.exe -h off

This command worked and removed the hiberfil.sys.

I agree, it’s really not a good idea to have that by default. The excuse that it exists in case of power-failure and switch to UPS makes no sense. You don’t need hiberfil.sys to protect you from power-failure. We’ve never had a problem with a properly configured UPS setup on a server when there is a powerfailure. If you turn off hibernation, the file should go away, period! If it’s turned off by default then the file shouldnt’ exist by default. Typical MS logic. Either way, not a big deal to get around.

ASP.NET Image Rollover Using VB

•June 23, 2010 • Leave a Comment

For a simple image rollover using your vb codebehind page and a couple of png files or whatever file type you wish to use. I’m not sure where I found this bit of script but it came in handy a few weeks ago!


<asp:ImageButton runat="server" ID="tbimage" ImageUrl="img/LeftMenuButton.png" Style="float: left;
outline: 0; width: 21px" />

In your VB Codebehind page:


    Private Sub Page_Load(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load

        tbimage.Attributes.Add("onMouseOver", _
            "this.src='img/LeftMenuButton2.png';")
        tbimage.Attributes.Add("onMouseOut", _
            "this.src='img/LeftMenuButton.png';")
      
    End Sub

Sending Email with System.Net.Mail

•June 23, 2010 • Leave a Comment

I haven’t tested this one but I got it off of ScottGu’s blog which has some great stuff on it…

Read Scott’s Original Post

.NET 2.0 includes much richer Email API support within the System.Net.Mail code namespace. I’ve seen a few questions from folks wondering about how to get started with it. Here is a simple snippet of how to send an email message from “sender@foo.bar.com” to multiple email recipients (note that the To a CC properties are collections and so can handle multiple address targets):


MailMessage message = new MailMessage();
message.From = new MailAddress("sender@foo.bar.com");

message.To.Add(new MailAddress("recipient1@foo.bar.com"));
message.To.Add(new MailAddress("recipient2@foo.bar.com"));
message.To.Add(new MailAddress("recipient3@foo.bar.com"));

message.CC.Add(new MailAddress("carboncopy@foo.bar.com"));
message.Subject = "This is my subject";
message.Body = "This is the content";

SmtpClient client = new SmtpClient();
client.Send(message);

 

System.Net.Mail reads SMTP configuration data out of the standard .NET configuration system (so for ASP.NET applications you’d configure this in your application’s web.config file). Here is an example of how to configure it:


  <system.net>
    <mailSettings>
      <smtp from="test@foo.com">
        <network host="smtpserver1" port="25" userName="username" password="secret" defaultCredentials="true" />
      </smtp>
    </mailSettings>
  </system.net>