本文介绍了html onclick =" [buttonname] _click"将不会开始与它相关的代码背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个添加用户页面,其上的按钮只是将网站重新启动到登录页面.

按钮的定义形式:

Hi,

I have an add user page and the buttons on it just restart the website to the login page.

button defined in form:

<asp:Button ID="btnAddUser" runat="server" onclick="btnAddUser_Click" Text="Add User" />



从设计器中双击该按钮,然后在.aspx.cs文件中将其打开



From the designer double clicked the button, and it opened in the .aspx.cs file

protected void btnAddUser_Click(object sender, EventArgs e)
        {
        }



放入代码以向SQL写入新用户后,它将重置为主页.不会通过C#代码. (尝试逐行尝试F11函数永远不会被调用).

据我所知,从登录页面到添加用户页面,我在表单上没有做任何不同...

不知所措,正在培训我的专业人士也无法理解它,现在周末去了..

需要一些帮助来完成此操作并解决下一个问题

谢谢,

BBB



After putting in the code to write a new user to SQL, it just resets to the main page. doesn''t go trough the c# code. (tried F11 step line by line the function never gets called).

As far as i can see i''ve done nothing different on the form from the login page to the add user page...

At a loss, and the professional guy who''s training me couldn''t figure it either and is now gone for the weekend....

need some help to finish this and get onto the next problem

thanks,

BBB

推荐答案

public partial class testsample: System.Web.UI.Page


<![CDATA[<%@ Page Language="C#" AutoEventWireup="true" CodeFile="testsample.aspx.cs" Inherits="testsample" %>]]>



因此,testsample必须匹配,以便调用正确的类.有时这是名称重复的代码处理问题.

好的,现在,如果您的page_load被触发,请检查
Page.IsPostBack
单击按钮时,它应该为true.

调试您的代码,看看是否有任何Response.End或其他东西阻碍进入button_click事件代码.

希望您的问题得到解决.

欢呼声



So the testsample must match so that the right class is invoked. This is sometimes a problem coping code with duplicate name.

Ok, now if your page_load fires, check
Page.IsPostBack
It should be true when you clicked the button.

Debug your code and see, if there is any Response.End or anaything which obstructs to go into the button_click event code.

Hope your problem will be solved.

cheers



这篇关于html onclick =&quot; [buttonname] _click&quot;将不会开始与它相关的代码背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 13:16