0
votes

Software: Visual Web Developer 2008 Express Edition

Book: Programming ASP.NET 3.5 by O'Reilly

The book says create source code in .aspx file

<head runat="server">
    <title></title>
</head>
    <script type="text" language="javascript">
        function ButtonTest(){
            alert("Button clicked - client side processing");
        }
        function DoChange(){
            document.getElementById("btnSave").disabled=false;
        }
    </script>
<body>
    <h1>Client-Side Processing</h1>
    <form id="form1" runat="server">
    <div>

        <input id="btnHTML" runat="server" onclick="javascript:ButtonTest();"
            onserverclick="btnHTML_ServerClick" type="button" value="HTML Button" />

Design view looks like this

enter image description here

Book says to double-click button in Design view to create event handler in the code behind file and to add the following highlighted line of code

protected void btnHTML_ServerClick(object sender, EventArgs e){

txtHTML.Value = "An HTML server control";

}

But when I double-click the HTML button, it takes me back to the .aspx file and there is no function btnHTML_ServerClick to add txtHTML.Value = "An HTML server control";

How to fix?

1

1 Answers

1
votes

An easy approach, without double-clicking, is to switch into the code-behind (f7 default shortcut) file and use the manager on the very top. Select your button (by ID) in the left dialog and the event in the right dialog. Afterwards your method will be created by vs.

Keep in mind that in the left dialog window only items with the runat="server"flag will be displayed