ultimate99 Posted August 20, 2009 Share Posted August 20, 2009 I'm receiving this error with the code provided. Compiler Error Message: BC30456: 'Click' is not a member of 'ASP.learning_survey_aspx'.Source Error: Line 40: <!-- Display confirmation button --> Line 41: <p> Line 42: <button id="confirmButton" OnServerClick="Click" Line 43: runat="server">Confirm</button> <!-- Display confirmation button --> <p> <button id="confirmButton" OnServerClick="Click" runat="server">Confirm</button> <script runat="server"> Sub submit(Source As Object, e As EventArgs) confirmation.Text="Confirmed" End Sub </script> <form runat="server"> <asp:Button id="confirmation" Text="Confirm" runat="server" OnServerClick="Click" /> </form> </p> I dont understand the error. Link to comment Share on other sites More sharing options...
0 Antaris Veteran Posted August 20, 2009 Veteran Share Posted August 20, 2009 It's expecting a method that has the name "Click", but your one has the name "submit", make the following change: Sub Click(Sender as Object, e As EventArgs) confirmation.Text = "Confirmed" End Sub Link to comment Share on other sites More sharing options...
0 Rohdekill Posted August 20, 2009 Share Posted August 20, 2009 (edited) It's expecting a method that has the name "Click", but your one has the name "submit", make the following change: Sub Click(Sender as Object, e As EventArgs) confirmation.Text = "Confirmed" End Sub try this: On front end remove the on server click. on back end: Protected Sub Confirmation(ByVal sender As Object, ByVal e As System.EventArgs) Handles confirmation.Click confirmation.Text = "Confirmed" End Sub Edited August 20, 2009 by Rohdekill Link to comment Share on other sites More sharing options...
0 ultimate99 Posted August 20, 2009 Author Share Posted August 20, 2009 Now I get this error. Compiler Error Message: BC30451: Name 'confirmation' is not declared.Source Error: Line 47: <script runat="server"> Line 48: Sub Click(Sender As Object, e As EventArgs) Line 49: confirmation.Text= "Confirmed" Line 50: End Sub Line 51: </script> Link to comment Share on other sites More sharing options...
0 sbauer Posted August 20, 2009 Share Posted August 20, 2009 Now I get this error. You're missing a server control with the ID of 'confirmation'. (ex. <asp:Label id="confirmation" runat="server"/>). If you have it on the page and you're using Visual Studio, open up your page in html view, switch to design view, and then switch it back to html view. Sometimes Visual Studio fails to write declarations in the partial class. Link to comment Share on other sites More sharing options...
0 ultimate99 Posted August 21, 2009 Author Share Posted August 21, 2009 ?Here's my code, in bold is where the error is, but I can't figure it out (confirmation.Text. I tried vs2008's suggestions but didn't work. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Using ASP.NET HTML Server Controls</title> <!-- code will go here --> </head> <body> <form runat="server"> <h2>Take the Survey!</h2> <!-- Display user name --> <p> Name:<br /> <input type="text" id="name" runat="server" /> </p> <!-- Display email --> <p> Email:<br /> <input type="text" id="email" runat="server" /> </p> <!-- Display technology options --> <p> Which server technologies do you use?<br /> <select id="serverModel" runat="server" multiple="true"> <option>ASP.NET</option> <option>PHP</option> <option>JSP</option> <option>CGI</option> <option>ColdFusion</option> </select> </p> <!-- Display .NET preference options --> <p> Do you like .NET so far?<br /> <select id="likeDotNet/option> </select> </p> <!-- Display confirmation button --> <p> <button id="confirmButton" OnServerClick="Click" runat="server">Confirm</button> <script runat="server"> Sub Click(ByVal Source As Object, ByVal e As EventArgs) [b]confirmation.Text[/b] = "Confirmed" End Sub </script> </p> <!-- Confirmation label --> <p> <asp:Label id="feedbacklabel" runat="server" /> </p> </form> </form> </body> </html> Link to comment Share on other sites More sharing options...
0 Antaris Veteran Posted August 21, 2009 Veteran Share Posted August 21, 2009 As sbauer has said, you don't actually have a control with that Id, so make this change: <script runat="server"> Sub Click(ByVal Source As Object, ByVal e As EventArgs) feedbacklabel.Text = "Confirmed" End Sub </script> Also, I noticed this: <select id="likeDotNet/option> </select> Which is sementically incorrect, and will no doubt cause the browser to mis-render your page. Link to comment Share on other sites More sharing options...
0 ultimate99 Posted August 21, 2009 Author Share Posted August 21, 2009 ok, thanks. I dont get an error anymore. But why the Confirm button is not showing? Also, I noticed this: <select id="likeDotNet/option> </select> Which is sementically incorrect, and will no doubt cause the browser to mis-render your page. Then what's correct, i didn't do any changes to this? Link to comment Share on other sites More sharing options...
0 Antaris Veteran Posted August 21, 2009 Veteran Share Posted August 21, 2009 <select id="likeDotNet" runat="server"> <option value="1">Yes</option> <option value="0">No</option> </select> That perhaps? As for the button, html looks alright now, maybe you are hiding it in CSS? Have you got this public anywhere we can check? Edit: It might not be visible because of the above issue with your html. Fix that and check again. Link to comment Share on other sites More sharing options...
0 sbauer Posted August 21, 2009 Share Posted August 21, 2009 <select id="likeDotNet" runat="server"> <option value="1">Yes</option> <option value="0">No</option> </select> That perhaps? As for the button, html looks alright now, maybe you are hiding it in CSS? Have you got this public anywhere we can check? Edit: It might not be visible because of the above issue with your html. Fix that and check again. Yeah, I'm sure that's what's causing it not to be displayed. I don't see anything else. Also, ultimate, it's not good practice to have your server-side script sitting in the middle of your html. Put it in a position that allows it to stand it (top of the page before your HTML, for example). Link to comment Share on other sites More sharing options...
0 ultimate99 Posted August 21, 2009 Author Share Posted August 21, 2009 <select id="likeDotNet" runat="server"> <option value="1">Yes</option> <option value="0">No</option> </select> That perhaps? As for the button, html looks alright now, maybe you are hiding it in CSS? Have you got this public anywhere we can check? Edit: It might not be visible because of the above issue with your html. Fix that and check again. This fixed the problem, thanks. Yeah, I'm sure that's what's causing it not to be displayed. I don't see anything else.Also, ultimate, it's not good practice to have your server-side script sitting in the middle of your html. Put it in a position that allows it to stand it (top of the page before your HTML, for example). Thanks for the tip. Thank you guys for your help. :) Link to comment Share on other sites More sharing options...
Question
ultimate99
I'm receiving this error with the code provided.
I dont understand the error.
Link to comment
Share on other sites
10 answers to this question
Recommended Posts