Archive for February, 2007

asp.net treeview drag and drop

I tried to provide drag and drop functionality to an asp.net treeview control for my CMS to change the website pages hierarchy just dragging the pages icons. I lost a lot of time because the ondragstart javascript event was never fired. This even was never fired because the TreeNode element always handles the onClick event without you choose to handle it. When the onClick event is fired the ondragstart event is never called.

What is the reason?
It happens because the treeNode element is always rendered with an <a href… onClick=”…”> </a> so it always handles the onClick.

If you try to do something like this:
dim tn as new TreeNode
tn.Text = “<img src=”"ico_htm.gif”" ondrop=’return drop(” + pagina.Oid.ToString() + “)’ ondragenter=’enterDrag()’ ondragover=’overDrag()’ ondragstart=’startDrag()’ ondragend=’endDrag()’ myLabel=’” + pagina.Oid.ToString() + “‘ border=0> Node text here”

The result will be:
<a href=# onClick=”…”><img src=”"ico_htm.gif”" ondrop=’return drop(” + pagina.Oid.ToString() + “)’ ondragenter=’enterDrag()’ ondragover=’overDrag()’ ondragstart=’startDrag()’ ondragend=’endDrag()’ myLabel=’” + pagina.Oid.ToString() + “‘ border=0> Node text here</a>

The treenode will be rendered inside an <a></a> tag so the ondragstart will never be fired.

What is the workaround?
It’s a simple trick to get rid of the <a> tag, all that you need is to start your treenode text with a </a> and finish with a <a href=#>.
This way you’ll remove the default treenode <a> tag just closing it before your HTML code starts but remember to open it again when your code is finished.

The result is:
dim tn as new TreeNode
tn.Text = “</a><img src=”"ico_htm.gif”" ondrop=’return drop(” + pagina.Oid.ToString() + “)’ ondragenter=’enterDrag()’ ondragover=’overDrag()’ ondragstart=’startDrag()’ ondragend=’endDrag()’ myLabel=’” + pagina.Oid.ToString() + “‘ border=0> Node text here<a href=#>”

Now that you know how to solve the treenode problem you just need to paste this Javascript code to do drag and drop

<script language=”JScript”><!–
var srcObj = new Object;
var dummyObj;
function startDrag(){
    srcObj = window.event.srcElement;
    dummyObj = srcObj.outerHTML;
    var dragData = window.event.dataTransfer;
    dragData.setData(’Text’, window.event.srcElement.src);
    dragData.effectAllowed = ‘Copy’;
    dragData.dropEffect = ‘move’;
}

function enterDrag() {
    window.event.dataTransfer.getData(’Text’);
}

function endDrag() {
    window.event.dataTransfer.clearData();
}

function overDrag() {
    window.event.returnValue = false;
}

function drop(x) {

if (confirm(’Are you sure to move the page?’)) {
if (confirm(’Really sure?’)) {
    window.event.returnValue = false;
alert(’Do you want the page : ‘ + srcObj.myLabel + ‘ to become a subpage of: ‘+x);
window.location=’YourPage.aspx?mode=move&idorig=’ + srcObj.myLabel + ‘&iddest=’ + x;
 }
}
return false;

}
–>
</script>

That’s all, i hope i’ve been clear enough.


TAGS: Asp.net, dotnet, code snippet, seo, search engine optimization, visual studio.net, sample code, c#, vb.net

win a citroen c2 or a plasma tv or caribbean travel

Yes you can win a Citroen C2 or a Caribbean Travel or a Sony Plasma TV

it’s not a joke, i explain you as you can win.

I’m competing to the SEO World Championship, the competition consist to be listed at the highest positions on Google, Yahoo and MSN when you search for globalwarming awareness2007
I decided to give away the prize, if i win , to one of the sites that helped me in this thing.
If my website will win one of the three prizes listed below it could be yours.
I thing it’s a good exchange for a simple text link to my website :) you don’t have to spend a $

the prizes for the winners are

1. Citroen C2 brand new car for the first place
2. A caribbean travel for the second place
3. A Sony Plasma TV for the thirth place

If you want to try just write a post on your blog talking about globalwarming and linking my competition website http://www.globalwarming-awareness2007.na.it on the keyword globalwarming awareness2007

Follow this link to get all the infos and submit your site so i can know that you’re helping me


TAGS: Asp.net, dotnet, code snippet, seo, search engine optimization, visual studio.net, sample code, c#, vb.net

Sell your domain with an auction

I was giving a look around for some way to make money :) and i noticed that the domain name after market is a very good opportunity. If you have a good domain name and it’s registration is old enough you can plan to sell it on tdnam.com
TDNAM is The Domain Name After Market, a service provided by Godaddy.com, there you can open a new auction to sell your domain. Before starting to sell you can get a domain name appraisal so you can figure out the possible selling price, maybe you’re rich but you don’t know yet. I request the appraisal for one of my domains and the resulting value was of 64.000$, not so bad :)

Godaddy gets about 5$ for a simple appraisal and about 15$ for a professional appraisal but you can find free appraisal sites all over the web.

If you’re planning to sell your domain go to www.tdnam.com and open your auction, i’ve seen domains selled for 250.000$, icredible but true!!!

Making money with the web is not so difficult, you just need to be a little lucky and know what the web can offer ;)


TAGS: Asp.net, dotnet, code snippet, seo, search engine optimization, visual studio.net, sample code, c#, vb.net

High Pagerank Sites

Hi, i discovered this new directory BLONG, you can visit it here High PR Sites | High Page Rank Websites | Directory , it’s a website collecting all High PageRank sites so if you need a link to your website you can easily find who can sell it to you.
Hope it helps :)


TAGS: Asp.net, dotnet, code snippet, seo, search engine optimization, visual studio.net, sample code, c#, vb.net

globalwarming awareness2007

It’s the keyword choosen for the SEO Wolrd Championship 2007.
I like very much this choice because the Global Warming is a really dangerous issue to be threated as soon as possible if there’s time left to recover the damages made by man.
Overheating is causing a lot of troubles all around the world and you can see it in Europe too. This year, for the first time, Europe has been invested by a tornado, it’s because of globalwarming for sure.
Italian Cities like Venice and Livorno have an high risk to be fully covered by sea and become the future Atlantis, it’s getting really dangerous… there’s no more time to waste.
Important informations about globalwarming awareness2007 can be found clicking these links:

Giuseppe Liguori globalwarming awareness2007 site
Ivano Di Biasi globalwarming awareness2007 site


TAGS: Asp.net, dotnet, code snippet, seo, search engine optimization, visual studio.net, sample code, c#, vb.net