Search This Blog

Tuesday, March 30, 2010

How do I open a new browser window?

To open a new browser window, use the window.open() method.
For example, the following code opens this page in a new window.

myRef = window.open(''+self.location,'mywin',
'left=20,top=20,width=500,height=500,toolbar=1,resizable=0');



The general syntax of the window.open() method is as follows:

winRef = window.open( URL, name [ , features [, replace ] ] )


The return value, stored in the variable winRef,
is the reference to your new window. You can use this reference later,
for example, to close this window (winRef.close()),
give focus to the window (winRef.focus()) or perform other
window manipulations.



The parameters URL, name, features, replace
have the following meaning:











URL

String specifying the location of the Web page to be displayed in the new window.
If you do not want to specify the location, pass an empty string as the URL
(this may be the case when you are going to write

some script-generated content to your new window).

name

String specifying the name of the new window.
This name can be used in the same constructions as the frame name provided
in the frame tag within a frameset <FRAME NAME=name ...>.
For example, you can use hyperlinks of the form
<a target=name href="page.htm">,
and the hyperlink destination page will be displayed in your new window.



If a window with this name already exists, then
window.open() will display the new content in that existing window,
rather than creating a new one.


features

An optional string parameter specifying the features of the new window.
The features string may contain one or more

feature=value pairs separated by commas.

replace

An optional boolean parameter. If true, the new location will replace
the current page in the browser's navigation history.
Note that some browsers will simply ignore this parameter.






The following features are available in most browsers:














toolbar=0|1

Specifies whether to display the toolbar in the new window.


location=0|1

Specifies whether to display the address line in the new window.



directories=0|1

Specifies whether to display the Netscape directory buttons.


status=0|1

Specifies whether to display the browser status bar.


menubar=0|1

Specifies whether to display the browser menu bar.


scrollbars=0|1

Specifies whether the new window should have scrollbars.


resizable=0|1

Specifies whether the new window is resizable.


width=pixels


Specifies the width of the new window.


height=pixels

Specifies the height of the new window.


top=pixels


Specifies the Y coordinate of the top left corner of the new window.
(Not supported in version 3 browsers.)


left=pixels

Specifies the X coordinate of the top left corner of the new window.
(Not supported in version 3 browsers.)

How to find Multiple connections to various databases on your SQL Server

SELECT distinct b.name
FROM master.dbo.sysprocesses a, master.dbo.sysdatabases b
WHERE b.dbid = a.dbid
AND a.uid = USER_ID(USER)

Friday, March 19, 2010

How to detect platform using javascript?

var platform = navigator.platform;

      alert('You are using'+ platform);

How to detect browser using javascript

You can detect your running browser as follows:

var browser = navigator.userAgent;

if(browser.indexOf('MSIE') !=-1)
        alert('You are using Internet Explorer');
else if(browser.indexOf('firefox') !=-1)
{
        alert('You are using Firefox');
}
else if(browser.indexOf('opera') !=-1)
{
        alert('You are using Opera');
}

Thursday, March 11, 2010

If it is intended as a parameter to a table-valued function, ensure that your database compatibility mode is set to 90.

if your database compatibility mode is not set to 90 then the below query

declare @d table (a varchar(10), b varchar(20))

insert into @d
values(11111,'1,23,4')
insert into @d
values(11112,'11,231,41')

select a, c.val
from @d cross Apply
fnStringtoTable( b ) c

will throw an error:

"b" is not a recognized table hints option. If it is intended as a parameter to a table-valued function, ensure that your database compatibility mode is set to 90.

If above error comes then do as follows:
EXEC sp_dbcmptlevel 'EZTEST' , 90
GO
declare @d table (a varchar(10), b varchar(20))

insert into @d
values(11111,'1,23,4')
insert into @d
values(11112,'11,231,41')

select a, c.val
from @d cross Apply
fnStringtoTable( b ) c

For More details visit here http://blogs.msdn.com/psssql/archive/2007/10/16/database-compatibility-and-new-features.aspx

Output:















ab
111111
1111123
111114
1111211
11112231
1111241

Thursday, March 4, 2010

How to read / download the content of a web page using C# and store it in a file?

Using below code you can read and download the content of of web page.
In this example strUrl is the of a web page and strFilePath is Physical location to save the contents.


using System;
using System.IO;
using System.Net;
using System.Text;

...

    public static void GetFile(string strURL,string strFilePath)
        {

            WebRequest myWebRequest = WebRequest.Create(strURL); 
            WebResponse myWebResponse = myWebRequest.GetResponse();              Stream ReceiveStream = myWebResponse.GetResponseStream();                
            Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
            StreamReader readStream = new StreamReader( ReceiveStream, encode );             string strResponse=readStream.ReadToEnd();                
            StreamWriter oSw=new StreamWriter(strFilePath);
            oSw.WriteLine(strResponse);
            oSw.Close();
            readStream.Close();
            myWebResponse.Close();
        }