tags:

views:

303

answers:

1

This code should not generate any HTML button dynamically. Coz there is no div in the <html></html> section.

But it is generating one.

Why?

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HtmlReWriting.aspx.cs" Inherits="JQuery_Intellisence_Test.HtmlReWriting" %>

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

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title> 
    <script src="Javascript/jquery-1.3.2.js" type="text/javascript">
     /// <reference path="Javascript/jquery-1.3.2-vsdoc.js" />
    </script>
    <script type="text/javascript">
        function ReWrite() {
            $('div').html('<input type="button" value="Button1" />');
     }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    </form>
    <input id="Button1" type="button" value="ReWrite HTML Element" onclick="ReWrite()" />
</body>
</html>
+2  A: 

You are looking into an ASP.NET page. This generates an HTML page that actually contains some divs. The jQuery code runs on the generated HTML, not at the ASP.NET source.

kgiannakakis
Yes you are right. I didn't look at the generated client code.
JMSA