BeetleDev.com
info
contact
Monday, October 06, 2008
Beetle Blog
1 2 3
By: douglas - ASP.net - 8/7/2008 1:15:13 AM

When you use a LinqDataSource as the datasource for a GridView you may run into an issue if you try to display data from a child object/table in the LinqDataSource.

For example if you have an object Order and child object Customer trying to call Customer.FirstName will be blank.  This is a bug in .net 3.5.

If you set EnableDelete, EnableInsert or EnableUpdate on the LinqDataSource the Eval statement will work.

Other workarounds and details can be found here:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2995461&SiteID=1

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2469812&SiteID=1


By: douglas - ASP.net - 5/28/2008 3:16:14 PM

This seems to be an error in the ASP.net runtime.

It can happen with MasterPages or UserControls.  Often it will happen after you update a file and place it on the server.   ASP.net is not able to always compile properly.

There is a hotfix from Microsoft for this.

http://support.microsoft.com/kb/915782

There is a workaround for this issue:

<configuration>

   
<system.web>
       
<compilation debug="false" batch="false"></compilation>
   
</system.web>

</configuration>


By: douglas - C# - 5/22/2008 3:56:27 AM

This code uploads an image to the server file system.  If the image is wider than a certain width it resizes the image.  The image is saved as a jpg.

 

        // Upload image
        // Make sure to create directory if needed.
        string savePath = Server.MapPath("~/UploadFolder/");

        // Create Directory if it doesn't exist
        if (!System.IO.Directory.Exists(savePath))
        {
            System.IO.Directory.CreateDirectory(savePath);
        }


        // Declare some image variables
        System.Drawing.Image imgOriginal;  // Will hold the original image
        System.Drawing.Image imgNew;  // Will hold the new image
        double targetWidth = 100; // Default target width for new image
        double targetHeight = 100; // Default target height for new image

        // Get new width from config
        try
        {
            targetWidth = Convert.ToDouble(ConfigurationManager.AppSettings["MaxImageWidth"]);
        }
        catch
        {
            targetWidth = 100;
        }

        //Create a new Image using the uploaded picture as a Stream
        imgOriginal = Bitmap.FromStream(ImageUpload.PostedFile.InputStream);

        // Work out a proportionate height from width
        if ((double)imgOriginal.Width < targetWidth)
        {
            targetWidth = (double)imgOriginal.Width;
            targetHeight = (double)imgOriginal.Height;
        }
        else
        {
            targetHeight = (double)imgOriginal.Height / ((double)imgOriginal.Width / targetWidth);
        }

        // Now create the new image
        imgNew = new Bitmap(imgOriginal, (int)targetWidth, (int)targetHeight);

        // Save it to the file system as a jpg.
        imgNew.Save(savePath + "\\" + pAdID.ToString() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
 


By: douglas - C# - 4/28/2008 6:13:14 AM

The following will validate stringVariable to see if it matches an email pattern.

System.Text.RegularExpressions.Regex.IsMatch(stringVariable, "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");

There are double \ due to the language being C#.

 


If you are using the command prompt on Windows many directories and file names have spaces in their names.  This does not work well with the command prompt.  One solution is to put double quotes around paths with spaces:

"C:\Program Files\My File.exe"

 


When you have an SqlDataSource that has a SelectCommand and Select parameters.  If the select parameters are optional or null the datasource will not return any records.

This may occur when using a stored procedure.  Testing the datasource in visual studio returns records and testing the stored procedure will also return records.  However the datasource and datagrid it binds to does not return any records.

The issue may be caused by a property in the SqlDataSource: CancelSelectOnNullParameter.  This property is defaulted to true and will prevent the select command from running if select parameters are null.

Set CancelSelectOnNullParameter="false"



By: douglas - ASP.net - 12/29/2007 12:23:55 AM

Here is how to start the standalone server that comes with VS.net 2005 and higher from the command line:

Start /B C:\WINDOWS\Microsoft.NET

\Framework\v2.0.50727\WebDev.WebServer.exe /port:1234 /path:"C:\YourWebSitePath"
 
If you place this line in a bat file you can start your web server by running the bat file.
 
WebDev.WebServer.exe is the web server.
 
 
 

By: douglas - Misc - 12/14/2007 6:37:16 PM

In VS.net 2005:

  1. Create a dataset file
  2. Drop a database table in the dataset
  3. Generate stored procedures
  4. Generate database insert, update, delete methods
  5. Close dataset file
  6. Open dataset file
  7. Configure dataset
  8. Go through wizard
  9. Now the generator does not generate the insert, update and delete methods
  10. This also happens if you create a new data set based on existing stored procedures

Possible workaround:


Creating a new TableAdapter in the DataSet Designer by right-clicking on the designer surface and choosing Add->TableAdapter. Then go through the wizard choosing Use Existing Stored Procedures. The checkbox will still be disabled but it will be checked and the DBDirect methods will be created. You will also be able to turn on/off the GenerateDBDirectMethods property in the properties window by following this workaround.


By: douglas - Misc - 11/12/2007 1:55:10 AM

Recently I've been working on animalpedia.com.  Animalpedia.com is a web site all about animals and I plan to make it a cross between a blog and wiki type site.  Hopefully it can be developed enough so that people will be able to use it as a resource for animal information and pictures.

Check it out at www.animalpedia.com.


By: douglas - ASP.net - 4/8/2007 3:29:13 PM
When using the PopupControl extender, if you run into an issue where the popup control does not pop up in the correct position when the page is scrolled you should make sure you have these HTML elements on your page:

<!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" >

By: douglas - Misc - 10/18/2006 1:45:37 AM
Recently I tried out Ubuntu (www.ubuntu.com).   I found it to be very easy to install and use.


By: douglas - ASP.net - 10/18/2006 1:23:27 AM
By default the ASP.net upload control is limited to around a 2 MB upload.  Trying to upload larger files result in an error.

To set the upload capacity of the upload control place these tags in the web.config:

<httpRuntime maxRequestLength="655350" useFullyQualifiedRedirectUrl="true" executionTimeout="600" />

Or:

<httpRuntime

executionTimeout="90"

maxRequestLength="4096"

useFullyQualifiedRedirectUrl="false"

minFreeThreads="8"

minLocalRequestFreeThreads="4"

appRequestQueueLimit="100"

/>


By: douglas - Misc - 10/28/2005 2:32:37 AM

Subversion is a source control system.

Subversion main link:
http://subversion.tigris.org/

 


By: douglas - Misc - 10/28/2005 2:28:54 AM

CruiseControl.net is a server that is used to run builds on software projects.

It works together with source control, NAnt, NUnit and other tools to build projects.

Here are some links to CruiseControl.net sites:

CCNet Main Site:
http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET

How to set up a CCNet project:
http://joefield.mysite4now.com/blog/articles/146.aspx

 


By: douglas - ASP.net - 9/24/2005 2:20:48 PM

These are good articles that show how to implement event bubbling with ASP.net.  Event bubbling is where an event in a user control can be handled by the parent page/control or another control.

http://authors.aspalliance.com/tempest/bubble.aspx

http://odetocode.com/Articles/94.aspx


By: douglas - Misc - 9/24/2005 2:18:01 PM

A friend of mine emailed me this link a couple of years ago.  It's an index on the popularity of programming languages.

http://www.tiobe.com/tpci.htm


Here is a good article show how to implement forms authentication and role based security using a database.

http://www.eggheadcafe.com/articles/20020906.asp


By: douglas - Misc - 6/17/2005 1:07:33 PM

This is how to do the meta refresh tag in plain HTML.

<meta http-equiv="refresh" content="0;URL=http://www.beetledev.com">

You can also use relative urls:

<meta http-equiv="refresh" content="0;URL=Home/default.aspx">


By: douglas - Misc - 6/10/2005 2:23:59 PM

I recently found a nice DNS lookup web site that allows you to look up information on a domain name.

http://www.dnsstuff.com/

Here is also another site that explains how DNS settings work:

http://www.rscott.org/dns/


By: douglas - Sql Server - 4/26/2005 2:07:56 AM
To change the owner of an SQL database object (for example a table or stored procedure) this sql procedure can be used:
 
sp_changeobjectowner '<current owner>.<object name>','<new owner>'
  • current owner = the current owner of the object
  • object name = the object's name (could be the table's name or stored procedure's name)
  • new owner = the database user that should be the new owner of the object

sp_changeobjectowner is a built in SQL server object.


1 2 3

Beetle Blog v0.2.2


Copyright © 1997 - 2008 BeetleDev.com. All rights reserved.