Is there any way to include javascript in wordpress.com blog

I have tried to include in-line javascript code but every time I failed. I wondered why the blog does not accept any javascript. This makes me very sad because I could not use any widgets that are designed in javascript. I tried to search in the net and failed to find any ideas to work with javascript. The samething also happens for Stylesheet or style tag.

Finally I found a link where it mentions that there are no ways to do all of these.

http://lorelle.wordpress.com/2005/09/16/using-javascript-in-wordpress/

Screen Scrap of Web Page

How about getting the contents of  url and set it in your own page? Well, you can use ASP.net to do that. Here is the codebehind code in C#

using System;
using System.Net;
using System.IO;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class tv_scrap : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnSubmit_Click(object sender, EventArgs e)
{
String strURL=txtUrl.Text;
String strHTML =String.Empty;

HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create(strURL);
objWebRequest.Method = “GET”;
HttpWebResponse objWebResponse = (HttpWebResponse)objWebRequest.GetResponse();
StreamReader streamReader = new StreamReader(objWebResponse.GetResponseStream());

strHTML = streamReader.ReadToEnd();
txtResponse.Text = strHTML;
lblResponse.Text = strHTML;

streamReader.Close();
objWebResponse.Close();
objWebRequest.Abort();
}
}

and the HTML code,

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="scrap.aspx.cs" ValidateRequest="false" Inherits="tv_scrap" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Screen Scraping</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:TextBox ID="txtUrl" runat="server" ></asp:TextBox>
    <asp:Button ID="btnSubmit" Runat="server" Text="Scrape Me!" OnClick="btnSubmit_Click" />
    <br/>
    <asp:TextBox ID="txtResponse" Runat="server" Width="800" Height="300" TextMode="MultiLine" />
    <br/>
    <asp:Literal ID="lblResponse" Runat="server" />
    </div>
    </form>
</body>
</html>

Maintain Scroll Position after Postback

When Web pages are posted back to the server, the user is returned to the top of the page. On long Web pages, this means that the user has to scroll the page back to the last position on the page.

In ASP.net, you can maintain the scroll position after postback. If you set Page.MaintainScrollPositionOnPostBack  to true, your last scroll position will not be lost . Try the following code,

<html xmlns=”http://www.w3.org/1999/xhtml“>
<head runat=”server”>
    <title>Untitled Page</title>
</head>
<body>
    <form id=”form1″ runat=”server”>
    <div style=”height:300px;border:1px solid green;”>
    Green
    </div>
    <div style=”height:300px;border:1px solid red;”>
    Red
    </div>
    <div style=”height:300px;border:1px solid blue;”>
    Blue
    </div>
    <div style=”height:300px;border:1px solid yellow;”>
    Yellow
    <asp:Button ID=”btnSubmit” runat=”server” OnClick=”btn_Clcik” Text=”Submit” />
    </div>
    </form>
</body>
</html>

Codebehind

public partial class tv_MaintainScrollPos : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Page.MaintainScrollPositionOnPostBack = true;
}

protected void btn_Clcik(object sender, EventArgs e)
{

}
}

Binary Write in ASP.net

Probably you have seen a lot of websites which have download facilities. You can give the link of the file in your site which can be a threat for your site because, the user can be able to know where have you put the file.Then what can be the solution?

You can use BINARYWRITE in asp.net which will solve the above problem. Here is the  code for BinaryWrite

FileStream MyFileStream = new FileStream(@”d:\inetpub\wwwroot\Afile.pdf”, FileMode.Open);
long FileSize;
FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length);
MyFileStream.Close();
Response.ContentType=”application/pdf”;
Response.AddHeader( “content-disposition”,”attachment; filename=AnotherPdf.PDF”);
Response.BinaryWrite(Buffer);

How can I improve my “Alexa Rank” ?

You can increase your site’s Alexa Rank significantly using Meta Redirect or any other kind of redirect on the Same Page. Every redirect will count as a Page View and thus contributing towards Better Alexa Rank. Meta Redirect on Same Page. Meta redirect code goes inside the …. tags of your HTML.

To redirect to a page, the syntax is nearly the same:

<meta http-equiv=”refresh” content=”20;url=http://www.ekduitin.wordpress.com/myPage.html” />

Here the number 20 is the time, in seconds, after which the page should be redirected. Then separated by a semi-colon (;) is the URL that should be loaded.

You can adjust the time so that a visitor does not get too annoyed. After all you need the traffic. Make sure you redirect to the same page.

Keep In Mind:
Meta redirect on same page have some drawbacks. Refreshing the current page can confuse people. If they didn’t request the reload, some people can get concerned about security.

You may find the above technique an Unfair Game. Here are some tips for you to Improve Alexa Rank in Fair Way:

  • Install the Alexa Toolbar on your computer. Everytime you visit your own site will be counted for you Alexa Ranking.
  • Get your Friends sign up for Alexa.
  • Put an Alexa widget on your site. Every click will be considered as a unique visit contributing towards improving your Alexa Ranking.
  • Join Social Networking sites . Number of visitors is an important factor for improve your Alexa Ranking.
  • Recommend your visitors use Alexa toolbar. As Alexa uses data collected from Alexa Toolbars this will greatly contribute Improving your Alexa Ranking.
  •  Join AutoSurf programs. Learn more about auto serf from  http://en.wikipedia.org/wiki/Autosurf

Alexa Ranking

Alexa ranks websites using the data it receives from stats of the users using the Alexa toolbar. But Alexa toolbar is not used by everyone. Then how can you increase your alexa ranking? An alternative way to notify Alexa of your site usage is to place the Alexa widget on you site itself. This makes sure that every site visit and page visit counts.
I have set one in one of my site and my ranking is going up day by day.

If you want one to include in your site, you can try :http://www.alexa.com/site/devcorner

See alexa ranking of this site.

Byte[] to Bitmap in ASP.net

Creating byte array from a file:

        String aFile = @”C:\\TEST\\chapter-ex_muji-t-shirt.jpg”;
        Byte[] bytes = null;

        FileStream fileStream = new FileStream(aFile, FileMode.Open, FileAccess.Read);
        bytes = new byte[(int)fileStream.Length];
        fileStream.Read(bytes, 0, (int)fileStream.Length);

using the above code, you can convert a file to Byte[].

Now , if you have the Byte[], you can convert that byte into bitmap,

        Bitmap thumbBitmap;
        ImageConverter ic = new ImageConverter();
        Image img = (Image)ic.ConvertFrom(bytes);

        thumbBitmap = new Bitmap(img);
        if (thumbBitmap != null)
        {
            Response.ContentType = “image/Jpeg”;
            thumbBitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
            thumbBitmap.Dispose();
        }

So you can convert Byte[]  to your desired bitmap.