A couple of hours ago I posted a question regarding my code doesn't work, after seeing answers and solutions and try them, my code still not working!
So I tried debugging tricks and tips to see what's going on and I noticed that the problem isn't in my code! It's because the button is not firing an event.
I've tried those solutions and none of them worked:
-
And then you get this:
Ok, so in above, we created a new web page called WebForm4.
We now have a blank web page, and it will have this markup:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="CSharpWebApp.WebForm4" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> </div> </form> </body> </html>
Ok, so now we drag drop in a button from the tool box - say like this:
So, we can hit ctrl-s for good measure.
Now, we have this:
Lets drag drop in a text box
So now we have this:
Now double click on button - we are auto jumped to code behind:
We can now enter code for button click event. Say this:
public partial class WebForm4 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { TextBox1.Text = "Hello World"; } }
now, f5 to run the page.
And if we click on the button, we get this:
So we assume you followed the above steps. And if not, then follow the above steps and post back what occurs.
So, create a WHOLE new web page - do NOT use any existing page.
CodePudding user response:
Thank you everyone for trying to answering the question.. I spent around 9 hours trying to see what is the problem, when I was checking all the files I saw a js lib code which was preventing the page from postbacking and sending requests, etc.. when I removed it everything worked prefectly.