function isUrl(s) {
var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
return regexp.test(s);
}
Archive for the ‘Uncategorized’ Category
Url Validation In Javascript
Posted in JavaScript, Uncategorized on June 16, 2009 | Leave a Comment »
Script To Search Text In Database
Posted in SQL, Uncategorized on April 3, 2009 | Leave a Comment »
DECLARE @SearchStr varchar(50)
SET @SearchStr = ‘Whatever’
SET NOCOUNT ON
DECLARE @Results TABLE ([Table] nvarchar(370), [Column] nvarchar(370), [Value] nvarchar(3630))
DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
SET @TableName = ”
SET @SearchStr2 = QUOTENAME(‘%’ + @SearchStr + ‘%’,””)
WHILE @TableName IS NOT NULL
BEGIN
SET @ColumnName = ”
SET @TableName =
(
SELECT MIN(QUOTENAME(TABLE_SCHEMA) + ‘.’ + QUOTENAME(TABLE_NAME))
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = ‘BASE TABLE’
AND QUOTENAME(TABLE_SCHEMA) + ‘.’ + [...]
Launch Cassini Using Command Line
Posted in .Net, CMD, Tools, Windows on March 27, 2009 | Leave a Comment »
taskkill /F /IM WebDev.WebServer.exe
START /D “C:\Program Files\Common Files\microsoft shared\DevServer\9.0\” /B WebDev.WebServer.EXE /port:5002 /path:”$PROJECT PATH” /vpath:”/PROJECT”
Example:
taskkill /F /IM WebDev.WebServer.exe
START /D “C:\Program Files\Common Files\microsoft shared\DevServer\9.0\” /B WebDev.WebServer.EXE /port:5002 /path:”d:\Projects\myproject\project.service” /vpath:”/Project.Service”
Max File Size Upload In ASP.Net
Posted in .Net, ASP.Net, Uncategorized on February 24, 2009 | Leave a Comment »
By default, the maximum file size to upload is 4MB. To increase it, simply add this section in web.config:
This will dictate the maximum size to be 5MB.
File MIME Type Using C#
Posted in .Net, C#, Windows on February 23, 2009 | Leave a Comment »
string fileName = “C:\\somefile.vsd”;
string mimeType = “application/unknown”;
string ext = System.IO.Path.GetExtension(fileName).ToLower();
Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
if (regKey != null && regKey.GetValue(“Content Type”) != null)
{
mimeType = regKey.GetValue(“Content Type”).ToString();
}
WCF Hosted In Multiple Environments
Posted in .Net, C#, Links, WCF on January 16, 2009 | Leave a Comment »
This is a great article from CodeProject: http://www.codeproject.com/KB/WCF/WCFMultipleHosting.aspx
Connection String In Production Environment
Posted in ASP.Net, IIS, SQL, Uncategorized on October 14, 2008 | Leave a Comment »
Things to do to setup a the right conection string in production:
The connection string shouldn’t have user in it, but the following: “Data Source=SERVER_NAME;Initial Catalog=DATABASE_NAME;Integrated Security=true;”
Create a user, say: User1 under “Local Users and Groups”. Set the password.
Change the application pool’s “Identity” to the user User1 just created.
Add in SQL Server the user using “Windows [...]
OnBeforeUnLoad Event
Posted in JavaScript, Uncategorized on August 21, 2008 | Leave a Comment »
As the window is closing, windows fire an event before onunload that the user can capture to do “something” before the window closes. Or, just prevent it from closing.
The code:
window.onbeforeunload = function()
{
return ‘Prompt message…’;
}
Page Postbacks And Client Callbacks
Posted in .Net, AJAX, ASP.Net, C#, HTML, JavaScript, Uncategorized on May 20, 2008 | Leave a Comment »
Interaction with a Web application can be initiated via a synchronous page postback or an out-of-band postback, known as a client callback, from the client to the server. The default ASP.NET Web page model uses synchronous page postbacks, which are usually triggered on the client by submitting an html form. During a page postback, the Web page and controls [...]
Filtering Non-Numeric Characters In A Textbox Using Javascript
Posted in HTML, JavaScript, Uncategorized on May 2, 2008 | Leave a Comment »
<html>
<head>
<script type=”text/javascript”>
var shiftOn = false;
var ctrlOn = false;
var altOn = false;
var focusedValue = “0″;
function validateNumeric(obj)
{
if (obj.value.length == 0)
{
obj.value = focusedValue;
return false;
}
[...]