View Single Post
  #9 (permalink)  
Old July 5th, 2011, 03:25 AM
Mahesha999 Mahesha999 is offline
Authorized User
Points: 51, Level: 1
Points: 51, Level: 1 Points: 51, Level: 1 Points: 51, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

JavaScript is working
This is the modified Page1.aspx to include an additional button that runs the JavaScript

Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Page1.aspx.cs" Inherits="Page1" %>

<!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></title>
    <script language="javascript" type="text/javascript">
// <![CDATA[

        function Button3_onclick() {
            //http://img715.imageshack.us/img715/7631/javascriptisactive.png
            alert("This is to test if the JavaScript works or not.");
        }

// ]]>
    </script>
</head>
<body>
    <form id="form1" runat="server">
        Enter your name:<br />
        <asp:Textbox ID="TextBox1" Runat="server"></asp:Textbox>
        <p>
            When do you want to fly?<br />
            <asp:Calendar ID="Calendar1" Runat="server"></asp:Calendar></p>
            <br />
            <asp:Button ID="Button1" Runat="server" Text="Submit page to itself" OnClick="Button1_Click" />
            <asp:Button ID="Button2" Runat="server" Text="Submit page to Page2.aspx" PostBackUrl="~/Page2.aspx" />
            <input id="Button3" type="button" value="Run JavaScript" onclick="return Button3_onclick()" />
        <p>
        <asp:Label ID="Label1" Runat="server"></asp:Label></p>
    </form>
</body>
</html>
Output Printscreen: http://img715.imageshack.us/img715/7...ptisactive.png

In the browser's html source window, the axd file's url seems something like this:

Code:
<script src="/PostBackUrl/WebResource.axd?d=yXPd-6jqJU9yUpgUop_GXLe959_q_LG_ul4NaiPWx5aj8oORGZE2cl-TVJKxf2ByJM96bXDpnwEuvNuyiPa56bnJZ75zvzulLnpDXuabk481&amp;t=634589204126647261" type="text/javascript"></script>
But when tried to request the file directly, following error occured:http://img841.imageshack.us/img841/9939/axderror.png

I googled for the same.
many people had this problem (about the postback, not specific to the axd file), they found different solutions that did not worked for me.

merk (third post) talked about the axd file problem at http://forums.asp.net/t/1052857.aspx/1. But did not explained how solved it to the length:

Last edited by Mahesha999; July 5th, 2011 at 03:28 AM.. Reason: edit