简体   繁体   中英

ASP.NET Events Not Firing

When I run my app local through the debug button my text box changed event fires after typing something in the text box and tabbing off of it.

But if I deploy to an IIS sever and test the site, the event doesn't fire.

What could be causing this problem?

UPDATE*** Sorry for the confusion. This has nothing to do with DEBUGGING and BREAKPOINTS. The events won't fire at all when deployed to IIS but they do fire when running locally

Try this:

After deploying your code to IIS and launching the website in your browser of choice, then go to the Debug menu in Visual Studio and choose Attach To Process... . This will open up a dialog window where processes are listed, check the box Show processes from all users. and then locate the w3wp.exe process in the list, now click the Attach button. It will take a little bit of time (seconds, not minutes) to load the symbols and make your break points active. Now when you generate events and have their handlers breakpointed on the server-side, the debugger will stop at the breakpoints just like when you pressed F5 in Visual Studio before deploying to IIS.

For more information read Attach to Running Processes with the Visual Studio Debugger

Its not really the standard behaviour that the event gets fired automatically after you tab out. For this to happen you have to say that the textbox should autopostback.

You should declare your asp:net textbox like this:

<asp:TextBox ID="helloWorldTextBox" runat="server" Text="Hello World!" AutoPostBack="True" OnTextChanged="helloWorldTextBox_TextChanged" />

If I understood you correctly you arent facing the problem of not being able to debug it, but simple that what ever should happen on the TextChanged Event isnt doing what it should do.

Another thing, if you are creating the textbox dynamically (in code behind) you have to make sure that the ID stays the same or the event wont fire. This is normally done in the Page_Init Event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM