.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

document.body.onload = ("javascript:initialize()")

Posted By:      Posted Date: October 22, 2010    Points: 0   Category :ASP.Net



    var geocoder, location1, location2, location3, gDir;
    function initialize() {
        geocoder = new GClientGeocoder();
        gDir = new GDirections();
        GEvent.addListener(gDir, "load", function () {
            var drivingDistanceMiles = gDir.getDistance().meters / 1609.344;
            var drivingDistanceKilometers = gDir.getDistance().meters / 1000;
            document.getElementById("Button2").value = drivingDistanceKilometers.toFixed(0);

Not work:

<script type="text/javascript">
            document.body.onload = ("javascript:initialize()")


Error in Microsoft JScript: 'document.body' has the value "null" or not an object

What's wrong?



<body onload="javascript:initialize()">

View Complete Post

More Related Resource Links

Replacing a text question in a Survey using JavaScript at runtime (document.body.innerHTML.replace)

Hi, I want to replace some of the text in a SharePoint Survey at runtime.  The idea behind that is to add a "header" or "title" to questions that are related together.  For example, let's say I have 2 related questions, a page separator, and 2 more related questions: (yes/no type of questions): Q1.  Are you between 20 and 40? Q2.  Did you went to college?   --page separator-- Q3.  J2EE Q4.  C/C++ The result on the final Survey should look like this: Tell us about you. Are you between 20 and 40?  Did you went to college?   --page separator-- Indicate what programming languages you know: J2EE C/C++ Simply, I tried to use the document.body.innerHTML.replace() in order to replace:  - Q1 with: <h2>Tell us about you.</h2>  - Q2 with ''  - Q3 with: <h2>Indicate what programming languages you know:</h2>  - Q4 with: '' Using the technique below, I added the following code in SharePoint Designer in NewForm.aspx: <asp:Content ContentPlaceHolderId="PlaceHolderTitleAreaClass" runat="server"> <script id="onetidPageTitleAreaFrameScript"> document.getElementById("onetidPageTitleAreaFrame").className="ms-areaseparator"; document.body.innerHTML = document.body.innerHTML.replace(/Q1/g,'

body onload


Hi everyone,

i have a gridview in which user insert the equipId and i am using the body onload event to pop up the message saying you have the same id exist once the user click ok it goes back to the page and focuses on the text box inside the gridview, till here its fine but after user enter different id and try to insert it into the girdview, it inserts fine but it pops up that message again. any idea here is my code for it

Body.Attributes.Add("onload", "javascript:alert('Same Equipment Code Found.Please enter different Equipment Code');");

sharepoint document.body.scrollTop


I tried to set a div to the center of screen even when scrolling in sharepoint 2010. However, the document.body.scrollTop alwasy return 0. I use the following code to get scrolledY:

 if (self.pageYoffset) {
            scrolledX = self.pageXoffset;
            scrolledY = self.pageYoffset;
        } else if (document.documentElement && document.documentElement.scrollTop) {
            scrolledX = document.documentElement.scrollLeft;
            scrolledY = document.documentElement.scrollTop;
        } else if (document.body) {
            scrolledX = document.body.scrollLeft;
            scrolledY = document.body.scrollTop;

If I run the above code outside of sharepoint, scrolledY gives me some value. if inside sharepoint, it gives me 0

Does any one know how to scrolledY?


getting the body onload event in a Contentplaceholder


Dear Friends,

I am displaying a map on a aspx web page using Mapserver and openlayers.
The map was being displayed fine on a normal aspx page.
Then I added a Masterpage to it and with it came 2 ContentPlaceholders.
I put the Div for displaying the map in one of the ContentPlaceholders.

But the problem is that map is no longer displayed.
For displaying the map I need to call a JS function init() in the body onload event.
But there is no body onload event in ContentPlaceholders.
I tried putting like this:

<script type="text/javascript" language="javascript">

body.onload = init();

function init()


But I get error.

How to tackle this problem?

Thanks for your responses.

Creating a Web Service to Recive a HTTP POST with an XML document as the body or payload from a PHP



I have been strugleing with this for more than a week, and have not been able to get any further ahead. I need to create a Webservice that can recive an HTTP Post with an XML document as the body or payload. It will be comeing from a PHP site, and I need to access it in ASP.Net.

I can create a webservice and test it out correctly with no real hitch, but when testing with my  third partys test page I am not getting the proper responce. The third party company can not provide me with much help since they do not know ASP.

The following is a sample code peice that can open a string of XML passed, and I have a form that can post to this test page.

public XmlDocument ProcessXML(String SourceXML)
XmlDocument NewSourceXML = new XmlDocument();



I knoiw that once I can read the posted XML I can break it down and do what I need to do with it, but I am having issues reciving the XML at this point.

My third party provided me with a basic excert from a PHP file.

 *  Get the HTTP request (body) and parse into an XML document
$data = file_get_contents("php://input");
$xmlstr = trim( stripslashes( $data ) );
$xml = new SimpleXMLElement($xmlstr);

But this is of no help to me. I need to

Working with SharePoint document libraries

Document libraries are collections of files that you can share with team members on a Web based on Microsoft Windows SharePoint Services. For example, you can create a library of common documents for a project, and team members can use their Web browsers to find the files, read them, and make comments. Users with Microsoft Office 2003 can check out and edit the files as if they resided on a local or network drive.

By default, your team Web site comes with a built-in document library named Shared Documents, which is listed on the Quick Launch bar as well as on the Documents and Lists page.

jQuery $(document).ready() and ASP.NET Ajax asynchronous postback

Many call it the ASP.NET jQuery postback problem, but using the technique below should make it no problem anymore. $(document).ready() isn't called after an asynchronous postback. What this means? You lose the functionality that should be executed within $(document).ready() after an UpdatePanel rendered its contents after an asynchronous postback.

SharePoint Document Workspaces for Developers

Office 2003 is being released this month, and a cast of supporting applications is already available. One of these is Windows SharePoint Services 2.0, the free team add-on for Windows Server 2003. If you're not familiar with SharePoint Services basics, take a look at What Developers Need to Know About Windows SharePoint Services. In this article, I'm going to drill into one key place where SharePoint and Office 2003 overlap: document workspaces

Upload a File to a SharePoint Document Library - Part I

The following helper class demonstrates a few techniques that allow documents to be uploaded to a SharePoint document library programmatically without using the API or a custom web service. You don't need to specify a document library name, and it will create any folders specified in the URL as required. File meta data will be updated if any properties are passed.

SharePoint document migration challenges when migrating files and folders

There are several challenges when migrating documents to Microsoft SharePoint. While these challenges can be overcome, they are a real pain if the migration source, content and file systems are not SharePoint friendly.

Charset Problem with dynamically generated Word Document


in my asp.net web application i am dynamically generating a word documnet out of a sql data. I have set the char set UTF-8 during the doument creation in code but still when i open the generated document and check it char set .. it is always windows-1252 not the one that i have set. My sql data in the document have special characters whihc can only be understandable using the UTF-8 charset otherwise its always ?T written in place of an apostrophy . Pasting my code here..

         HttpContext.Current.Response.ContentType = "application/msword";
         HttpContext.Current.Response.ContentEncoding = System.Text.UnicodeEncoding.UTF8;
         HttpContext.Current.Response.Charset = "utf-8";
         string strFileName = "Details" + ".doc";
        HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName);
        StringBuilder strHTMLContent = new StringBuilder();
        string strMessage = " ";
        DataView abstractview = (DataView)dsAbstract.Select(DataSourceSelectArguments.Empty);
        foreach (DataRowView row1 in abstractview)
            strMessage += "<table border='1' cellspacing='0' cellpadding='5' width

Embed word document inside excel



I am using ASP.NET and C# 2.0 and working on web application.

I want to embed a word document inside a excel sheet.

How to embed word document inside excel.

Thank you



statement cannot appear outside of a method body


hi all,

  i am posting my vb.net problem .plz tell me how to resolve this :-

Dim conn As String = ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString
    'Dim mysqlconnection As New SqlConnection(conn)
    'If mysqlconnection.State=ConnectionState.closed Then mysqlconnection.Open();
    'Dim mySqlcommand As New SqlCommand("select CategoryId,CategoryName from Categories", mysqlconnection)
    'Dim mySqlDataAdapter As New SqlDataAdapter(mySqlcommand)
    'Dim mydataSet As New DataSet()

    'if mysqlconnection.State=ConnectionState.closed Then mysqlconnection.Open();

i m getting 5 errors in this code

declaration expected in mySqlDataAdapter.Fill method; Gridview1.DataSource=ds; Gridview1.DataBind();

Office Development: Manage Metadata with Document Information Panels


Here the author uses Document Information Panels in the Microsoft 2007 Office system to manipulate metadata from Office docs for better discovery and management.

Ashish Ghoda

MSDN Magazine April 2008

Advanced Basics: Setting Word Document Properties the Office 2007 Way


The last time I wrote this column (March 2006), I shared an application that allows you to update all the Microsoft® Word documents in a folder and its subfolders. Each time the application finds a document in the specified path, it updates the document properties to match those you specified in the application.

Ken Getz

MSDN Magazine June 2006

Advanced Basics: Set Word Document Properties Programmatically


At the beginning of another lovely day of writing courseware in mad pursuit of unrealistic deadlines, I received a frantic call from a business partner. He was at the end of a long consulting project and had several hundred Microsoft® Word documents, all of which required their document properties to be set identically, except the Title property of the document, which was to be based on the document file name, minus the .

Ken Getz

MSDN Magazine March 2006

XML Comments: Document Your Code in No Time At All with Macros in Visual Studio


Starting in Visual Studio 2005, XML documentation support will become available in Visual Basic and C++ as it has been for C#. However, making full use of the many comment tags will take a little extra work In this article, the author shows how Visual Studio macros can be used to automate the creation of XML documentation and creates macros that write large sections of comments with just a keystroke.

Tony Chow

MSDN Magazine July 2005

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend