Jul182010

sql stuff

Published by Pete Celliers at 4:40 PM under

for procedures

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'') AND type in (N'P', N'PC'))
drop PROCEDURE
go

 

for views

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[matching].[workingset_patient_episodes]') AND type in (N'V'))
drop view [matching].[workingset_patient_episodes]
go

 



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses

Jul132010

Batch commands

Published by Pete Celliers at 11:43 AM under

COPY %windir%\filename a:

SETLOCAL
..... set vars only local to batch file
ENDLOCAL

START .....
/minimized or /m
/maximized
or /max
/restored
or /r
/wait
or /w

IF EXIST some.txt COPY c:/some.dll %windir%/SYSTEM/some.dll   (IF NOT EXISTS)

IF ERRORLEVEL 4 ERASE trashfile.tmp /P

IF %M%==1 GOTO SavedIt
:SavedIt

FOR variable in (set list) DO command .... or DO ( ... commands ... )
FOR %%D in (SYSTEM, COMMAND, SHELLNEW, "Start Menu") DO DIR "%windir%\%%D" /W

SET /P M=Type 1, 2, or 3, then press ENTER:
IF %M%==1 GOTO EXPORT
IF %M%==2 GOTO IMPORT

dir /s /f (recurs, files only)



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses

Jul132010

AssemblyCulture

Published by Pete Celliers at 10:45 AM under Errors

Error: Unable to cast object of type 'System.Web.Compilation.BuildResultCompiledAssembly' to type 'System.Web.Compilation.BuildResultCompiledGlobalAsaxType'

Solution:

search for "AssemblyCulture" and make sure to delete the culture or put a valid one in.
e.g. [assembly: AssemblyCulture("THIS_IS_INVALID")]

 



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses

Jul082010

how z-index works in css

Published by Pete Celliers at 6:57 PM under CSS

z-index: 1;
position: absolute;

An object with a larger z-index than another will be in front of the other object

 



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses

Jun282010

SQL 2008 modifying table structures from within Management Studio

Published by Pete Celliers at 5:16 PM under Errors | SQL SERVER

The error message:

Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.


This can be fixed by the following steps:

Tools -> Options -> Designer Page -> "Prevent saving changes that require table re-creation" -> uncheck



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses

Jun282010

readonly CheckBox or CheckBoxList

Published by Pete Celliers at 12:45 PM under c# | CSS | Javascript

Simply add the following to your declaration:
onclick="return false;" 

This will disable the javascript that ticks / unticks the box.

Examples of both readonly CheckBoxLists and readonly CheckBoxListes:

<asp:CheckBoxList ID="CheckBoxList1" runat="server" onclick="return false;">
<asp:CheckBox ID="CheckBox1" runat="server" onclick="return false;" Text="test" />

 

 



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses

May212010

Floating a webpage in the middle of the screen

Published by Pete Celliers at 1:07 PM under

use the following CSS in your stylesheet:

body
{
   margin: 0px auto; /* this is what does the trick */
   padding: 0px;
   width: 800px;
}



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses

May202010

Content controls are allowed only in content page that references a master page

Published by Pete Celliers at 5:29 PM under Errors

Solutions to the following error:

Content controls are allowed only in content page that references a master page

You get this error when you have no masterpage assigned to your web form

Options to consider (other than simply adding your masterpage statically):

 You can derive all your pages from a base page in the web config file:

    <system.web>
      <pages pageBaseType="BasePage" >

then create a class and declare it as follow:

    public class BasePage : System.Web.UI.Page { ....

with the following method in it:

    protected override void OnPreInit(EventArgs e)
    {
        string ThemeName = "Bitlink";
        //this should point to your masterpage:
        MasterPageFile = VirtualPathUtility.ToAbsolute(("~/")) + "Themes/" + ThemeName + "/Master.master";
        base.OnPreInit(e);
    }

this way all your pages would be assigned to a certain masterpage dynamically.

 



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses

May182010

regular expressions in c#

Published by Pete Celliers at 11:33 AM under c# | regular expressions

Characters

identifier

definition

\a

Alert, x07.

\b

Backspace, x08.

\e

ESC, x1B.

\n

Newline, x0A.

\r

Carriage return, x0D.

\f

Form feed, x0C.

\t

Tab, x09.

\v

Vertical tab, x0B.

\0octal

Two-digit octal character code.

\xhex

Two-digit hexadecimal character code.

\uhex

Four-digit hexadecimal character code.

\cchar

Named control character.

Classes

identifier

definition

[...]

Single character from the listed range.

[^...]

Single character not from the listed range.

.

Any single character except for a line terminator (unless in single-line mode - s).

\w

Word character such as [a-zA-Z_0-9]

\W

Non-word character - basically [^a-zA-Z_0-9]

\d

Digit [0-9]

\D

Non-digit [^0-9]

\s

Whitespace character such as [ \f\n\r\t\v]

\S

Non-whitespace character

\p{prop}

Character that is contained in the specified Unicode block / property.

\P{prop}

Character that is not contained in the specified Unicode block / property.

Tests etc

identifier

definition

^

Start of a string, or following a newline in MULTILINE mode.

\A

Beginning of string, in all match modes.

$

End of string or before any newline if in MULTILINE mode.

\Z

End of string but before any final line terminator, in all match modes.

\z

End of string in all match modes.

\b

Boundary between a \w character and a \W character.

\B

Not-word-boundary.

\G

End of the previous match.

(?=...)

Positive lookahead.

(?!...)

Negative lookahead.

(?<=...)

Positive lookbehind.

(?<!...)

Negative lookbehind.

mode modifiers

mode

identifier

definition

Singleline

s

Dot (.) matches any character, including a line terminator.

Multiline

m

^ and $ match next to embedded line terminators.

IgnorePatternWhitespace

x

Ignore whitespace and allow embedded comments starting with #.

IgnoreCase

i

Case-insensitive match based on characters in the current culture.

CultureInvariant

i

Culture-insensitive match.

ExplicitCapture

n

Allow named capture groups, but treat parentheses as non-capturing groups.

Compiled

 

Compile regular expression.

RightToLeft

 

Search from right to left, starting to the left of the start position.

ECMAScript

 

Enables ECMAScript compliance when used with IgnoreCase or Multiline.

(?imnsx-imnsx)

 

Turn match flags on or off for rest of pattern.

(?imnsx-imnsx:...)

 

Turn match flags on or off for the rest of the subexpression.

(?#...)

 

Treat substring as a comment.

#...

 

Treat rest of line as a comment in /x mode.

groups and repititions

identifier

definition

(...)

Grouping. Submatches fill \1,\2,... and $1, $2,....

\n

In a regular expression, match what was matched by the nth earlier submatch.

$n

In a replacement string, contains the nth earlier submatch.

(?<name>...)

Captures matched substring into group, name.

(?:...)

Grouping-only parentheses, no capturing.

(?>...)

Disallow backtracking for subpattern.

...|...

Alternation; match one or the other.

*

Repeated 0 or more times.

+

Repeated 1 or more times.

?

Repeated 1 or 0 times.

{n}

Repeated exactly n times.

{n,}

Repeated at least n times.

{x,y}

Repeated at least x times, but no more than y times.

*?

Repeated 0 or more times, but as few times as possible.

+?

Repeated 1 or more times, but as few times as possible.

??

Repeated 0 or 1 times, but as few times as possible.

{n,}?

Repeated at least n times, but as few times as possible.

{x,y}?

Repeated at least x times, no more than y times, but as few times as possible.

Replacements

identifier

definition

$1, $2, ...

The captured submatches.

${name}

The matched text for a named capture group.

$'

Text before match.

$&

Text of match.

$'

Text after match.

$+

Last parenthesized match.

$_

Original input string.

 



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses

May162010

Right Click and Auto Row Select with a ContextMenuStrip

Published by Pete Celliers at 12:31 PM under c#

If you have a datagridview and want to be able to right-click, which should automatically selecte the row that you've clicked and fire the ContextMenuStrip, it can be done as follows:

 

private void dataGridView1_MouseClick(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right)
    {
        foreach (DataGridViewRow s in dataGridView1.SelectedRows)
            s.Selected = false;
 
        DataGridView.HitTestInfo hit = dataGridView1.HitTest(e.X, e.Y);
        dataGridView1.Rows[hit.RowIndex].Selected = true;
        dataGridView1.CurrentCell= dataGridView1.Rows[hit.RowIndex].Cells[hit.ColumnIndex];
        contextMenuStrip1.Show(dataGridView1, new Point(e.X,e.Y) );
    }
}


[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses

Apr282010

Value cannot be null. Parameter name: propName

Published by Pete Celliers at 6:43 PM under Errors

you get the error: Value cannot be null. Parameter name: propName

the reason could be (it was in my case) that the gridview you are trying to bind contains a comma with no further fields as follow:

  .... DataKeyNames="FullNo1,StudyNo,"

feel free to post other solutions to this error



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses

Apr222010

app settings in web.config

Published by Pete Celliers at 7:05 PM under c#

 In web.config:

<appSettings>
    <add key="ContactUsEmail" value="me@mysite.com"/>
</appSettings>

In your code:

using System.Configuration;

        private void SendEmail(string emailbody)
        {
                string V = (string)ConfigurationSettings.AppSettings["ConnectionInfo"];
        }

 



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses

Apr192010

asp net maintain scroll position on postback

Published by Pete Celliers at 4:04 PM under c#

either in you web.config file you can add the following entry:

<system.web>
      <pages theme="standard" maintainScrollPositionOnPostBack="true">
</system.web>
 

or for any page you can set the page directive as follow:

<%@ Page MaintainScrollPositionOnPostback="true" .... 



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses

Apr152010

user agent

Published by Pete Celliers at 6:35 PM under c#

The following line will provide the useragent from the person accesing your web page

 HttpContext.Current.Request.Headers["User-Agent"]

 it would look similar to the following:

useragent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9 GTBDFff GTB7.0 (.NET CLR 3.5.30729)

 

 



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses

Apr142010

The 'Microsoft.Jet.OLEDB.4.0' provider is not registered

Published by Pete Celliers at 12:36 PM under Errors

This happens if you run your application in 64bit
(using the Jet for excel etc)

simply switch to 32bit 



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 0 Responses