AddClass and removeClass on moveover on a list using jquery asp.net csharp

28. May 2010

In this article, author try to tell us how to append and remove class on client side using jquery and css style.

Reference:Addclass and removeClass on moveover on a list using jquery asp.net csharp

online demo


Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL, asp.net, CSS, HTML, JQuery , , ,

Adjust Auto Height of Iframe using asp.net JQuery

31. March 2010
My first attempt failed both in Internet Explorer and Firefox, worst in Firefox which announced that iframe.document didn’t have any properties, and in Internet Explorer the div element was placed after the iframe
element not inside intended.To configure this script,first, set the variables inside the script of Step 1 per the comments. As you can see, you can specify more than one iframe on the page in which the
script should dynamically Auto Adjust (resize).where "myframe" is the ID of the IFRAME you wish to load a page into, and "iframe.aspx", the
path to the page on your site to load.But happy to have found myself.

iframe code

  1. Opening tag
  2. iframe page source
  3. height of the iframe
  4. width of the iframe
  5. Non-iframe content (What to display in the users' browser if they are not capable of viewing iframes.)
  6. Closing tag
src Specified the URL of the document to be displayed in the frame.
src="FileName.html"
name Specifies the name of the frame for the purpose of linking and targeting.
name="MyIframe"
width
height
Specifies the width/height of the iframe space in pixels or percentages.
width="200" height="100"
align Aligns the iframe to the left, center, or right side of the page.
align="center"
noresize Kills the visitors ability to resize the iframe borders manually.
noresize="noresize"
scrolling Indicates the ability of a scrollbar to appear (or not) with a value of yes, no, or auto.
scrolling="auto"
frameborder Carries a value of 0 or 1 depending if you want a border to appear around the iframe or not.
frameborder="1"
marginwidth
marginheight
Specifies the width/height of the margin in pixels.
marginwidth="1" marginheight="1"
vspace
hspace
Specifies the verticle/horizontal margin space in pixels.
vspace="1" hspace="1"


Accessing the document inside an iframe

When dealing with inline frames (iframe), it is common to have the need to access the document loaded into the iframe.




Default.aspx Page
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="jquery.js"></script>

</head>
<body>
<form id="form1" runat="server">
<div>
<iframe id="myframe" name="myframe" frameborder="1" scrolling="no" src="Default2.aspx"></iframe>
</div>
</form>
</body>
</html>


Copy Page Javascript function on Default.aspx Page.


//created by Aamir Hasan
//Date April,1 2010
function doIframe() {
o = document.getElementsByTagName('iframe');
for (i = 0; i < o.length; i++) {
setHeight(o[i]);
addEvent(o[i], 'load', doIframe);

}
}

function setHeight(e) {

if (e.contentDocument) {
e.height = e.contentDocument.body.offsetHeight + 35;
} else {
e.height = e.contentWindow.document.body.scrollHeight;
}
}

function addEvent(obj, evType, fn) {
if (obj.addEventListener) {
obj.addEventListener(evType, fn, false);
return true;
} else if (obj.attachEvent) {
var r = obj.attachEvent("on" + evType, fn);
return r;
} else {
return false;
}
}

if (document.getElementById && document.createTextNode) {
addEvent(window, 'load', doIframe);
}

Warning

In order to support the most browsers with the least headaches, it is best to use the highly-compatible "DOM0" frames collection, which is a child of window.

Inlcude jquery.js in your Default.aspx Page

jquery.js (122.64 kb)


Compatibility

This code has been tested on and is known to work in:

  • Internet Explorer 6 (Win), 5.5 (Win)
  • Mozilla 1.7.5 (all) - Firefox 1.0 - Filefox 3.6.2
  • Safari 1.2.4, Safari 3.1.1
  • Opera 7.54 (Win), Opera 9.8 (Win)

Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

Ajax, asp.net, HTML, JQuery , , ,

Center Page Content Horizontally using Div with CSS

18. March 2010

Center your website content to create equal sized Space from  the left and right using css. Horizontally centered by setting its right and left margin widths to "auto". This is the preferred way to accomplish horizontal centering with CSS. Create a warpper div which will hold your content div and then give it a margin:auto attribute which will bring your warpper div into center of page.




<html>
<head>
<title>Center Page Content Horizontally and Vertically using Div with CSS </title>

 <style type="text/css">
body{background-color:#eaeaea;}
  #wrapper {width: 777px;margin:auto}
  #content{background-color:#00FF00;min-height:400px;}
  </style>
  </head>
  <body>
  <form id="form1" runat="server">
  <div id="wrapper">



 <div id="wrapper">

  <div id="content">
  Welcome to Studentacad.com
  </div>


  </div>
  </form>
  </body>
</html>

Center Page Content Horizontally and Vertically using Div with CSS 

 
  
  
  
Welcome to Studentacad.com


Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL, CSS, HTML ,

To Avoid it prompts IE's printer dialog box.

2. January 2010

To Avoid it prompts IE's printer dialog box.


if (navigator.appName == "Microsoft Internet Explorer")
{
     var PrintCommand = '<object ID="PrintCommandObject" WIDTH=0 HEIGHT=0
CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
     document.body.insertAdjacentHTML('beforeEnd', PrintCommand);
     PrintCommandObject.ExecWB(6, -1); PrintCommandObject.outerHTML = "";
}
else {
window.print();
}


Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL, asp.net, HTML , ,

set dynamic height width with respect to content of a inner page(firefox,IE,IE7,IE8,Opera,Safari)

1. January 2010

set dynamic height width with respect to content of a inner page(firefox,IE,IE7,IE8,Opera,Safari)
this will work on all broswer like IE,firefox,Opera,Safari
<script type="text/javascript" language="javascript">
function collectWidth(obj) {
var wVal = 0
var objs = obj.document.getElementsByTagName('*')
for (var i_tem = 0; i_tem < objs.length; i_tem++) {
wVal = Math.max(objs[i_tem].offsetWidth, wVal)
}
return wVal;
}

function sizeFrameHeightWidth(frameObj) {
if ((frameObj.contentDocument && (frameObj.contentDocument.body.offsetHeight || frameObj.contentDocument.documentElement.offsetHeight)) || frameObj.Document && frameObj.Document.body.scrollHeight) {
var contentHeight = window.opera ? frameObj.contentDocument.documentElement.offsetHeight : frameObj.contentDocument ? frameObj.contentDocument.body.offsetHeight : frameObj.Document.body.scrollHeight + 4
var contentWidth = window.opera ? collectWidth(frameObj.contentDocument) : frameObj.contentDocument ? frameObj.contentDocument.documentElement.offsetWidth : frameObj.Document.body.scrollWidth
var frameWidth = frameObj.offsetWidth
if (window.opera && frameWidth >= contentWidth)
frameObj.contentDocument.body.style.overflow = 'hidden'
frameObj.style.overflow = 'visible'
frameObj.height = frameWidth < contentWidth ? contentHeight + 18 : contentHeight + 30;
}

}
</SCRIPT>


inside the body tag
<body>


<div>



<iframe name="I3" onload="sizeFrameHeightWidth(this)" src=http://studentacad.com marginwidth="0" marginheight="0" vspace="0" hspace="0" frameborder="0" scrolling=no width="100%" height="350"></iframe>
<iframe name="I5" onload="sizeFrameHeightWidth(this)" src=AamirHasan.asmx marginwidth="0" marginheight="0" vspace="0" hspace="0" frameborder="1" width="100%" height="270"></iframe>
</div>



</body>


Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL, HTML, Javascript , ,



User Name: Guest

Your Ip: 38.107.191.92
Time: