Hi All,
I was browsing in the internet just to check is it possible just to have a block with curved images without using images.
Many of the links are as usual only, but there was one link which said doing without images, i got excited and opened the link, as they mentioned it was like that.
So i just thought of sharing with you all.
Many of you might think it is just copying and pasting the code, but believe me i tried it out and then only i am posting it here :) :)
I will explain the logic at the last.
HTML:
< class=" b1 ">< / b >< class=" b2 ">< / b >< class=" b3 "> < / b > < class=" b4 ">< / b >
< class="content">
<>
<> <>You can see me with curved edges.< / td >< / tr >
< / table >
< / div >
< class=" b4 ">< / b >< class=" b3 ">< / b >< class= " b2 "> < / b > < class=" b1 "> < / b >
CSS:
<>
.b1 { DISPLAY: block; FONT-SIZE: 1px; OVERFLOW: hidden }
.b2 { DISPLAY: block; FONT-SIZE: 1px; OVERFLOW: hidden }
.b3 { DISPLAY: block; FONT-SIZE: 1px; OVERFLOW: hidden }
.b4 { DISPLAY: block; FONT-SIZE: 1px; OVERFLOW: hidden }
.b1 { BACKGROUND: #888; MARGIN: 0px 5px; HEIGHT: 1px }
.b2 { BORDER-RIGHT: #888 2px solid; BACKGROUND: #ddd; MARGIN: 0px 3px; BORDER-LEFT: #888 2px solid; HEIGHT: 1px }
.b3 { BORDER-RIGHT: #888 1px solid; BACKGROUND: #ddd; MARGIN: 0px 2px; BORDER-LEFT: #888 1px solid; HEIGHT: 1px }
.b4 { BORDER-RIGHT: #888 1px solid; BACKGROUND: #ddd; MARGIN: 0px 1px; BORDER-LEFT: #888 1px solid; HEIGHT: 2px }
.contentb { BORDER-RIGHT: #888 1px solid; BACKGROUND: #ddd; BORDER-LEFT: #888 1px solid }
.contentb DIV { MARGIN-LEFT: 5px }
.contentb TABLE { MARGIN-LEFT: 5px }
< / style >
save the code as html file and TADA you can see the curved edges without images.
As i promised the logic is just simple, setting the margin for the bold tag would actually make a curved apperance to the edges
Reference : http://www.html.it/articoli/nifty/index.html
Have a happy coding
Venkat :)
Thursday, July 16, 2009
Monday, January 26, 2009
how to get the styles from a parent window in javascript
Hi,
Recently i had a scenario, which i had to load a page in a iframe, it was working fine, but the problem was the styles was not setting up in the child window, i cannot hard code the styles as the style sheets will be generated dynamically and i will be able to get the styles, i tried to find out a way, did some googling and found the way in javascript.
call the javascript function in child window onload, it will take care of the rest
function setParentStyle()
{
if(window.top && window.top.location.href != document.location.href)
{
// all parent's <link> tag's
var linkrels = window.top.document.getElementsByTagName('link');
// my head - child window head tag
var small_head = document.getElementsByTagName('head').item(0);
// loop through parent's links
for (var i = 0, max = linkrels.length; i < max; i++)
{
// are they stylesheets
if (linkrels[i].rel && linkrels[i].rel == 'stylesheet')
{
// create new element and copy all attributes
var thestyle = document.createElement('link');
var attrib = linkrels[i].attributes;
for (var j = 0, attribmax = attrib.length; j < attribmax; j++)
{
thestyle.setAttribute(attrib[j].nodeName, attrib[j].nodeValue);
}
// add the newly created element to the head
small_head.appendChild(thestyle);
}
}
}
}
i am just copying and pasting it what i got, there is nothing which i did on my own :) :)
Thanks
Venkat
Recently i had a scenario, which i had to load a page in a iframe, it was working fine, but the problem was the styles was not setting up in the child window, i cannot hard code the styles as the style sheets will be generated dynamically and i will be able to get the styles, i tried to find out a way, did some googling and found the way in javascript.
call the javascript function in child window onload, it will take care of the rest
function setParentStyle()
{
if(window.top && window.top.location.href != document.location.href)
{
// all parent's <link> tag's
var linkrels = window.top.document.getElementsByTagName('link');
// my head - child window head tag
var small_head = document.getElementsByTagName('head').item(0);
// loop through parent's links
for (var i = 0, max = linkrels.length; i < max; i++)
{
// are they stylesheets
if (linkrels[i].rel && linkrels[i].rel == 'stylesheet')
{
// create new element and copy all attributes
var thestyle = document.createElement('link');
var attrib = linkrels[i].attributes;
for (var j = 0, attribmax = attrib.length; j < attribmax; j++)
{
thestyle.setAttribute(attrib[j].nodeName, attrib[j].nodeValue);
}
// add the newly created element to the head
small_head.appendChild(thestyle);
}
}
}
}
i am just copying and pasting it what i got, there is nothing which i did on my own :) :)
Thanks
Venkat
Saturday, October 4, 2008
simple way to check a site is secured or not
Recently when i was creating dynamic url's in my application, i wanted to know how to know is the site is using https or normal http, when i searched in google i got a simple solution which i want to share,
"Request.IsSecureConnection"
if(Request.IsSecureConnection)
{
Response.Write("secured");
}
else
{
Response.Write("not secured");
}
"Request.IsSecureConnection"
if(Request.IsSecureConnection)
{
Response.Write("secured");
}
else
{
Response.Write("not secured");
}
Saturday, August 23, 2008
Ajax in classic ASP
Hi,
Till now all these 2 years of my IT exp, i have been working in aspx pages only and for ajax i was using the ajax dll only, but recently i got a chance to work in classic asp page where i had to implement ajax in a asp page, i have heard before that it is possible to do it with xmlhttprequest object, but i have not tried it till now, as i have to work on it, before applying it in my application, i did some googling and then worked on some sample pages to know about it, even though it irritated me a little when trying but at the end i was satisfied that i learnt a new concept, so i would like to share one of my sample pages,
it needs a xml file and a html file, for which i have placed the code below
====================================================================================
Customers.xml
< ?xml version="1.0" encoding="utf-8" ? >
< Root >
< Customers >
< Name >Customer1< / Name >
< Address >Address1< / Address >
< City >City1< / City >
< State >State1< / State >
< / Customers >
< Customers >
< Name >Customer2< / Name >
< Address >Address2< / Address >
< City >City2< / City >
< State >State2< / State >
< / Customers >
< Customers >
< Name >Customer3< / Name >
< Address >Address3< / Address >
< City >City3< / City >
< State >State3< / State >
< / Customers >
< Customers >
< Name >Customer4< / Name >
< Address >Address4< / Address >
< City >City4< / City >
< State >State4< / State >
< / Customers >
< Customers >
< Name >Customer5< / Name >
< Address >Address5< / Address >
< City >City5< / City >
< State >State5< / State >
< / Customers >
< Customers >
< Name >Customer6< / Name >
< Address >Address6< / Address >
< City >City6< / City >
< State >State6< / State >
< / Customers >
< Customers >
< Name >Customer7< / Name >
< Address >Address7< / Address >
< City >City7< / City >
< State >State7< / State >
< / Customers >
< Customers >
< Name >Customer8< / Name >
< Address >Address8< / Address >
< City >City8< / City >
< State >State8< / State >
< / Customers >
< Customers >
< Name >Customer9< / Name >
< Address >Address9< / Address >
< City >City9< / City >
< State >State9< / State >
< / Customers >
< Customers >
< Name >Customer10< / Name >
< Address >Address10< / Address >
< City >City10< / City >
< State >State10< / State >
< / Customers >
< / Root >
====================================================================================
save the above content as a xml file named as customers.xml (removing the spaces in between the content)
====================================================================================
Test.html
< html >
< head >
< title >Sample XML HTTP< / title >
< script language="javascript" type="text / javascript" >
function GetCustomers()
{
var xmlHttp, strPgUrl
xmlHttp = CreateXmlObject();
if(xmlHttp == null)
{
alert('Sorry, your browser does not support XmlHttpRequest');
return;
}
strPgUrl = "Customers.xml";
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 1)
{
document.getElementById('loading').innerHTML = "Loading...";
}
if(xmlHttp.readyState == 4)
{
var xmlDoc = xmlHttp.responseXML.documentElement;
if(xmlDoc != null)
BindCustomerInfo(xmlDoc);
document.getElementById('loading').innerHTML = "";
}
}
xmlHttp.open("GET",strPgUrl,true);
xmlHttp.send(null);
}
function BindCustomerInfo(xmlDoc)
{
var TotalCount, strContent;
TotalCount = xmlDoc.getElementsByTagName("Customers").length;
if(TotalCount != 0)
{
strContent = "< table border='1' cellpadding='1' cellspacing='1' >";
for(var icnt = 0;icnt< TotalCount;icnt++)
{
strContent += "< tr >";
strContent += "< td >";
strContent += xmlDoc.getElementsByTagName("Name")[0].childNodes[0].nodeValue;
strContent += "< / td >";
strContent += "< td >";
strContent += xmlDoc.getElementsByTagName("Address")[icnt].childNodes[0].nodeValue;
strContent += "< / td >";
strContent += "< td >";
strContent += xmlDoc.getElementsByTagName("City")[icnt].childNodes[0].nodeValue;
strContent += "< / td >";
strContent += "< td >";
strContent += xmlDoc.getElementsByTagName("State")[icnt].childNodes[0].nodeValue;
strContent += "< / td >";
strContent += "< / tr >";
}
strContent += "< / table >";
document.getElementById('Customers').innerHTML = strContent;
}
}
function CreateXmlObject()
{
var xmlHttp = null;
try
{
xmlHttp = new XMLHttpRequest(); / / Opera, Safari, Firefox
}
catch(e)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); / / IE
}
catch(e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
function ClearData()
{
document.getElementById('Customers').innerHTML = "";
}
< / script >
< / head >
< body >
< table >
< tr >
< td >
< input type="button" value="Get Customers" id="btnget" onclick="GetCustomers()" / >
< input type="button" value="Clear" id="btnclear" onclick="ClearData()" / >
< / td >
< / tr >
< tr >
< td >
< span id="loading" >< / span >
< / td >
< / tr >
< tr >
< td >
< span id="Customers" >< / span >
< / td >
< / tr >
< / table >
< / body >
< / html >
====================================================================================
likewise save the above content as test.html
In the customers.xml file, it just contains customer information.
In the test.html, it has 2 input buttons one to get the customer information and the other to clear the fetched data.
the GetCustomers() javascript method will intially create a xml http object using the CreateXmlObject() method, the CreateXmlObject() will create the xmlhttp object for all browsers.
after the object is created it will call the generic method to send a request to fetch the data and binds the data in to a span element.
i hope the above information is enough to understand the concept
if needed let me know, i will explain more in detail
Cheers
Venkat
Till now all these 2 years of my IT exp, i have been working in aspx pages only and for ajax i was using the ajax dll only, but recently i got a chance to work in classic asp page where i had to implement ajax in a asp page, i have heard before that it is possible to do it with xmlhttprequest object, but i have not tried it till now, as i have to work on it, before applying it in my application, i did some googling and then worked on some sample pages to know about it, even though it irritated me a little when trying but at the end i was satisfied that i learnt a new concept, so i would like to share one of my sample pages,
it needs a xml file and a html file, for which i have placed the code below
====================================================================================
Customers.xml
< ?xml version="1.0" encoding="utf-8" ? >
< Root >
< Customers >
< Name >Customer1< / Name >
< Address >Address1< / Address >
< City >City1< / City >
< State >State1< / State >
< / Customers >
< Customers >
< Name >Customer2< / Name >
< Address >Address2< / Address >
< City >City2< / City >
< State >State2< / State >
< / Customers >
< Customers >
< Name >Customer3< / Name >
< Address >Address3< / Address >
< City >City3< / City >
< State >State3< / State >
< / Customers >
< Customers >
< Name >Customer4< / Name >
< Address >Address4< / Address >
< City >City4< / City >
< State >State4< / State >
< / Customers >
< Customers >
< Name >Customer5< / Name >
< Address >Address5< / Address >
< City >City5< / City >
< State >State5< / State >
< / Customers >
< Customers >
< Name >Customer6< / Name >
< Address >Address6< / Address >
< City >City6< / City >
< State >State6< / State >
< / Customers >
< Customers >
< Name >Customer7< / Name >
< Address >Address7< / Address >
< City >City7< / City >
< State >State7< / State >
< / Customers >
< Customers >
< Name >Customer8< / Name >
< Address >Address8< / Address >
< City >City8< / City >
< State >State8< / State >
< / Customers >
< Customers >
< Name >Customer9< / Name >
< Address >Address9< / Address >
< City >City9< / City >
< State >State9< / State >
< / Customers >
< Customers >
< Name >Customer10< / Name >
< Address >Address10< / Address >
< City >City10< / City >
< State >State10< / State >
< / Customers >
< / Root >
====================================================================================
save the above content as a xml file named as customers.xml (removing the spaces in between the content)
====================================================================================
Test.html
< html >
< head >
< title >Sample XML HTTP< / title >
< script language="javascript" type="text / javascript" >
function GetCustomers()
{
var xmlHttp, strPgUrl
xmlHttp = CreateXmlObject();
if(xmlHttp == null)
{
alert('Sorry, your browser does not support XmlHttpRequest');
return;
}
strPgUrl = "Customers.xml";
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 1)
{
document.getElementById('loading').innerHTML = "Loading...";
}
if(xmlHttp.readyState == 4)
{
var xmlDoc = xmlHttp.responseXML.documentElement;
if(xmlDoc != null)
BindCustomerInfo(xmlDoc);
document.getElementById('loading').innerHTML = "";
}
}
xmlHttp.open("GET",strPgUrl,true);
xmlHttp.send(null);
}
function BindCustomerInfo(xmlDoc)
{
var TotalCount, strContent;
TotalCount = xmlDoc.getElementsByTagName("Customers").length;
if(TotalCount != 0)
{
strContent = "< table border='1' cellpadding='1' cellspacing='1' >";
for(var icnt = 0;icnt< TotalCount;icnt++)
{
strContent += "< tr >";
strContent += "< td >";
strContent += xmlDoc.getElementsByTagName("Name")[0].childNodes[0].nodeValue;
strContent += "< / td >";
strContent += "< td >";
strContent += xmlDoc.getElementsByTagName("Address")[icnt].childNodes[0].nodeValue;
strContent += "< / td >";
strContent += "< td >";
strContent += xmlDoc.getElementsByTagName("City")[icnt].childNodes[0].nodeValue;
strContent += "< / td >";
strContent += "< td >";
strContent += xmlDoc.getElementsByTagName("State")[icnt].childNodes[0].nodeValue;
strContent += "< / td >";
strContent += "< / tr >";
}
strContent += "< / table >";
document.getElementById('Customers').innerHTML = strContent;
}
}
function CreateXmlObject()
{
var xmlHttp = null;
try
{
xmlHttp = new XMLHttpRequest(); / / Opera, Safari, Firefox
}
catch(e)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); / / IE
}
catch(e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
function ClearData()
{
document.getElementById('Customers').innerHTML = "";
}
< / script >
< / head >
< body >
< table >
< tr >
< td >
< input type="button" value="Get Customers" id="btnget" onclick="GetCustomers()" / >
< input type="button" value="Clear" id="btnclear" onclick="ClearData()" / >
< / td >
< / tr >
< tr >
< td >
< span id="loading" >< / span >
< / td >
< / tr >
< tr >
< td >
< span id="Customers" >< / span >
< / td >
< / tr >
< / table >
< / body >
< / html >
====================================================================================
likewise save the above content as test.html
In the customers.xml file, it just contains customer information.
In the test.html, it has 2 input buttons one to get the customer information and the other to clear the fetched data.
the GetCustomers() javascript method will intially create a xml http object using the CreateXmlObject() method, the CreateXmlObject() will create the xmlhttp object for all browsers.
after the object is created it will call the generic method to send a request to fetch the data and binds the data in to a span element.
i hope the above information is enough to understand the concept
if needed let me know, i will explain more in detail
Cheers
Venkat
Monday, August 18, 2008
Alternative solution for innerText for non IE browsers
In my application i was dynamically generating a html and my requirement was to get all the text inside a td and populate it in a select box using javascript, i was using innerText property in javascript and was populating all the contents, i sent it to QA department and the next day they sent it back saying its not working in firefox, then only i realised i should have checked in firefox, when i checked it in firefox it was showing only undefined...
then after googling i found a solution that works in IE, firefox and opera.
to get the innertext of a table element textcontent should be used, i have added a sample for reference
< html >
< head >
< script >
window.onload = function()
{
var text = (navigator.appName != 'Netscape') ? "innerText" : "textContent";
alert(document.getElementById('t1')[text]);
alert(document.getElementById('t2')[text]);
}
< / script >
< / head >
< table >
< tr >< td id='t1' >Row1 Col1< / td >< / tr >
< tr >< td id='t2' >Row2 Col1< / td >< / tr >
< / table >
< / html >
just save above code as a html file removing the spaces and open in all browsers vollah....
Cheers
Venkat
then after googling i found a solution that works in IE, firefox and opera.
to get the innertext of a table element textcontent should be used, i have added a sample for reference
< html >
< head >
< script >
window.onload = function()
{
var text = (navigator.appName != 'Netscape') ? "innerText" : "textContent";
alert(document.getElementById('t1')[text]);
alert(document.getElementById('t2')[text]);
}
< / script >
< / head >
< table >
< tr >< td id='t1' >Row1 Col1< / td >< / tr >
< tr >< td id='t2' >Row2 Col1< / td >< / tr >
< / table >
< / html >
just save above code as a html file removing the spaces and open in all browsers vollah....
Cheers
Venkat
Sunday, August 17, 2008
How to Select random row from a table - Ms Sql Server
One day my boss was asking me to populate data from a table to a temporary table, but he dont want me to popuplate the entire data, he wants me to select some random rows from the table and insert into the table.
so for the requirement i tried and found this...
SELECT * FROM [TableName] ORDER BY NEWID()
NEWID() generates a uniqueindentifier, so when ordering the data by the id it will select some random data
Cheers
Venkat.
so for the requirement i tried and found this...
SELECT * FROM [TableName] ORDER BY NEWID()
NEWID() generates a uniqueindentifier, so when ordering the data by the id it will select some random data
Cheers
Venkat.
A start...
Being the first post let me make one thing very clear... If you need som great techinical stuff bout dot net (DN).. im realy sory... this is not ur place and thanks for visiting my page...!!!
On the other hand this page is meant for sharing som hot happng n new stuff's in DN.. im not a DN geek but i learn many things each day and i will be sharing them in this page.. So gals n guys welcome aboard for an exciting journey to the world of DT..!!
Happy DT'ng....!!!!
Cheers...
Venkat
On the other hand this page is meant for sharing som hot happng n new stuff's in DN.. im not a DN geek but i learn many things each day and i will be sharing them in this page.. So gals n guys welcome aboard for an exciting journey to the world of DT..!!
Happy DT'ng....!!!!
Cheers...
Venkat
Subscribe to:
Posts (Atom)