ASP.NET (35) SQL (25) JAVASCRIPT (24) HTML (14) STYLE SHEET (6) ASP (4) SCRIPT (1)

Search me out HERE!!

HOW TO GET POSITION OF PARTICULAR OBJECT USING JAVASCRIPT

Below JavaScript function is used to get position of any object.

function findPos()
{
      //Here 'myTextbox' is object whose position is calculated.
      obj = document.getElementById('myTextbox');
      var posX = obj.offsetLeft;
      var posY = obj.offsetTop;
      while(obj.offsetParent)
     {
      posX=posX+obj.offsetParent.offsetLeft;
      posY=posY+obj.offsetParent.offsetTop;
      if(obj==document.getElementsByTagName('body')[0]){break}
      else{obj=obj.offsetParent;}
      }
//posX and posY are postion of required object.
}

Changing image on mouse hover in anchor tag

Below code is used to change IMAGE in anchor code on Mouse Hover.

Include Below SCRIPT:
<script language="javascript" type="text/javascript">
/**
 * flip(imgName, imgSrc) sets the src attribute of a named
 * image in the current document. The function must be passed
 * two strings. The first is the name of the image in the document
 * and the second is the source to set it to.
 **/
function flip(imgName, imgSrc){
   if (document.images){
      document[imgName].src = imgSrc
   }
}
</script>


Now you code for ANCHOR Tag will be:
<a HREF="nextPage.html" onMouseOver="flip('Register', 'images/test_hover.gif')"
     onMouseOut ="flip('Register', 'images/test.gif')">                               
     <img src="images/test.gif" alt="Register" name="Register" width="185" border="0">

</a>

Note: Here test.gif is visible by default and test_hover image will be visible on Mouse Hover.

BULK INSERT INTO TABLE FROM COMMA SEPERATED .txt FILE IN SQL

Below code can be used in SQL SERVER 2005 to insert bulk value in Table from .txt file (Values are separated by comma ',' ).

BULK
INSERT testing_table
FROM 'c:\testing.txt'
WITH
(
    FIELDTERMINATOR = ',',
    ROWTERMINATOR = '\n'
)

GO

Note : c:/testing.txt is file from which data need to be uploaded. Also here testing.txt file will contain values with ',' separator and new row is in new line.

TO SET VISIBILITY OF VARIOUS ITEMS IN .rdlc REPORT IN ASP.Net DURING RUN TIME

Select the Object for which you want to set visibility on Run Time. Then in Property section there in Property name 'VISIBILITY', in that set HIDDEN Expression as given below:

=iif(Fields!test.Value.ToString().Equals("true"),true,false)

If this expression is TRUE then that object will not be visible. By default its HIDDEN value is set to FALSE.
So if certain object need to be made invisible then pass "true" in dataset, which can be checked in if condition & hence HIDDEN property can be changed accordingly.

In Above example i have passed value in 'test'. If 'test' is true, then object will be not be visible and if 'test' is false then object will be visible.

CONVERT STRING INTO FLOAT WITH FIX DECIMAL PLACES IN ASP.NET

Below code is used to get float number in fix decimal places:


float flag;
flag = float.Parse(string.Format("{0:0.00}", number));

Eg:
number = 3.453432;
flag = float.Parse(string.Format("{0:0.00}", number));
// output : flag=3.45

TO USE GLOBAL PARAMETER FROM WEB.CONFIG FILE

Below mention is code to access Connection string from Web.Config file. Here you can have multiple variables.

Write this in Web.Config file :


<configuration> 
  <appSettings> 
     <add key="ConnectionString" value="server=localhost;uid=sa;pwd=;database=DBPerson" /> 
  </appSettings>
</configuration>

//Here value is Connection String used to connect with database
 Now you can access above value in your web page as given below: 
using System.Configuration;
string connectionString = ConfigurationSettings.AppSettings["ConnectionString"].ToString();


Note:Similarly you can add multiple KEY which you want as global variable.

Various tab to INCLUDE IN HEAD part for SEO and better search result

Below tags should be included in Head part with proper content to get SEO.

<meta name="google-site-verification" content="" ></meta>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" ></meta>
<meta name="Author" content="COMPANY NAME" ></meta>
<meta name="Keywords" content="Here comes various keywords with ',' separator" ></meta>
<meta name="description" content="HERE COMES YOUR DESCRIPTION" ></meta>
<meta name="Copyright" content="? 2009-2010 www.website.com"></meta>
<meta name="Publisher" content="Company name." ></meta>
<meta name="document-classification" content="TAG LINE" ></meta>
<meta name="document-type" content="Public" ></meta>
<meta name="document-distribution" content="Global" ></meta>
<meta name="robots" content="ALL, INDEX, FOLLOW"></meta>
<meta name="googlebot" content="index, follow" ></meta>
<meta name="revisit-after" content="7 Days" ></meta>
<meta name="Expires" content="never" ></meta>

From above, it is not necessary to include all META tags. Basic and important META tag are KEYWORDS & DESCRIPTION

POP UP WINDOW USING JAVASCRIPT

Following Javascript function is used to pop up new window when we click on any link:

PUT THIS FUNCTION IN JAVASCRIPT
function showevent ()
{
          window.open("test.html", "nw",'titlebar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=120,left=200,width=600,height=400')

}

NOW ON LINK TAG. i.e. A TAG, ADD
<a href="javascript:showevent();" >OPEN WINDOW</a>


Whenever we will click on LINK, test.html page will open. Here any page instead of test.html can be used, which you want to POP UP.