TipsOnLips.net

Your .net tips and tricks source

About the author

Author Name is someone.
E-mail me Send mail

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010


Add controls to Visual Studio IDE Toolbox (drag and drop)

To add controls to the Visual Studio IDE from an assembly, just drag this assembly or DLL from Windows Explorer to

VS IDE toolbox and you will get all the controls showing on the Toolbox.

 


Categories: VS 2005
Posted by developer on Thursday, August 16, 2007 10:27 PM
Permalink | Comments (2) | Post RSSRSS comment feed

Call a Web service using basic authentication

 To call a Web service using basic authentication us the following;

 

using System.Net;

localhost.MyWebService myService = new localhost.MyWebService();

System.Net.CredentialCache myCredentials = new System.Net.CredentialCache();

NetworkCredential netCred = new NetworkCredential("UserName", "Password");

myCredentials.Add(new Uri(myService.Url), "Basic", netCred);

myService.Credentials = myCredentials;


Categories: ASP.NET | C# | Web Services
Posted by Admin on Thursday, August 16, 2007 7:14 AM
Permalink | Comments (4) | Post RSSRSS comment feed

Disable Request Validation in ASP.NET page

 Request Validation - Preventing Script Attacks You can turn off the protection for a single page by

inserting this directive at the top:  

<%@ Page="" validateRequest="false" %>

Or you can turn it off for the entire website in the web.config file:         

<configuration>

              <system.web>                   

           <pages validateRequest="false" />             

          </system.web>

</configuration>


Categories: ASP.NET
Posted by developer on Wednesday, August 15, 2007 4:20 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Sorting hash table in C#

When adding key/value items to a hashtable the rows will be sorted in a way follows the items are

effective in the order of the hashed that are generated by the keys.
http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/d771e4bb-721c-4c68-bffd-6142e0f7e0c7/.


Thefore its better either to create a collection object or use the System.Collection.Specialised.ListDirectory

which sorts the records in the order was entered.


Categories: C#
Posted by Admin on Wednesday, August 15, 2007 1:58 AM
Permalink | Comments (6) | Post RSSRSS comment feed

Using Gridview.DataKeys

Gridview.DataKeys[e.Row.RowIndex].Value can be used to get the key of a specific row in a GridView.

If the row was selected then .DataKeys[gridview.SelectedIndex].Value.

 


Categories: ASP.NET
Posted by developer on Tuesday, August 14, 2007 10:54 AM
Permalink | Comments (1) | Post RSSRSS comment feed

Get an SQL Server current transaction id

SELECT TOP 1
  @transactionID = req_transactionID
 FROM
  master..syslockinfo l
 INNER JOIN
  master..sysprocesses p ON l.req_spid = p.spid AND l.rsc_dbid = p.dbid AND p.spid = @@spid
 WHERE
  l.rsc_dbid = db_id() AND p.open_tran != 0 AND req_transactionID > 0
 ORDER BY
  req_transactionID

Categories: SQL Server
Posted by developer on Monday, August 13, 2007 10:06 PM
Permalink | Comments (6) | Post RSSRSS comment feed

Get a Web page file name

To get a Web page file name use the following:

System.IO.Path.GetFileName(System.Web.HttpContext. Current.Request.Url.AbsolutePath)


Categories: ASP.NET
Posted by developer on Monday, August 13, 2007 5:04 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Submit parameters from page to another page

To submit parameters from one page to another that can be in many ways:

  a)Query Strings
  b)Previous Page
  c)Session in the base form
  d)ViewState in the page (please test)

 


Categories: ASP.NET
Posted by developer on Monday, August 13, 2007 5:02 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Add Print CSS tags (@media print)

When applying a print.css to a master page, if the content page has the theme referencing an existing them,

then it does not show an image. The way to do it is to use this statement in the Css file;

 

@media print

{

…Print Css tags

}

@media screen

{

….Normal Css tags

}


Categories: CSS
Posted by Admin on Monday, August 13, 2007 4:52 AM
Permalink | Comments (1) | Post RSSRSS comment feed

A javascript link can be used to call a javascript function as below:

A javascript link can be used to call a javascript function as below:

<a href="javascript:;" onclick="openWindow('../../Pages/Help/PopupForms/SelectDisplayType.aspx')">

<img src="../../images/icons/question_sm.gif" border="0" tabindex="-1" />

</a>


Categories: JavaScript
Posted by developer on Monday, August 13, 2007 4:46 AM
Permalink | Comments (0) | Post RSSRSS comment feed