ASP.NET表单默认按钮不工作。

ASP.NET表单默认按钮不工作。,asp.net,forms,login,Asp.net,Forms,Login,ASP.NET默认按钮和默认焦点不工作。我的应用程序托管在我的服务器manchine中的IIS上。(Servername说Server1)。如果我正在访问机器焦点之外的应用程序URL,并且默认按钮单击正常(http://Server1/VPath/Login.aspx) . 如果我在服务器中使用localhost访问应用程序URL,它工作正常(http://localhost/VPath/Login.aspx)但是,当我在服务器中使用服务器名称访问URL时,焦点和默认按钮单击(按Enter键)不

ASP.NET默认按钮和默认焦点不工作。我的应用程序托管在我的服务器manchine中的IIS上。(Servername说Server1)。如果我正在访问机器焦点之外的应用程序URL,并且默认按钮单击正常(http://Server1/VPath/Login.aspx) . 如果我在服务器中使用localhost访问应用程序URL,它工作正常(http://localhost/VPath/Login.aspx)但是,当我在服务器中使用服务器名称访问URL时,焦点和默认按钮单击(按Enter键)不起作用。(http://server1/VPath/Login.aspx). 可能是什么问题

注意:IE版本在上述所有情况下都是相同的

这是我的代码文件

Login.aspx
我不知道为什么你的代码在从外部访问时不起作用,但我认为问题出在这里 与
page_init
事件一起出现

因此,我建议最好覆盖它,这也是安全的:-

protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        Response.RedirectLocation = Request.Url.ToString();
        // bug#19156 Enter key should Login
        LoginControl.Focus();
        Page.Form.DefaultButton = ((Button)LoginControl.FindControl("LoginButton")).UniqueID;
    }

您是否尝试过为面板提供默认按钮,如:?是的,我尝试过,但没有使用。仍然面临相同的错误:(
 protected void Page_Init(object sender, EventArgs e)
    {
        Response.RedirectLocation = Request.Url.ToString();
        // bug#19156 Enter key should Login
        LoginControl.Focus();
        Page.Form.DefaultButton = ((Button)LoginControl.FindControl("LoginButton")).UniqueID;
    }

protected void Page_Load(object sender, EventArgs e)
    {
        log.Debug("Loading login Page");
        try
        {
            if (Request.QueryString["activity"] != null)
            {
                string activity = Request.QueryString["activity"].ToString();
                switch (activity)
                {
                    case "login":
                        if (Request.QueryString["Username"] != null)
                            un = Request.QueryString["Username"].ToString();
                        if (Request.QueryString["Password"] != null)
                            pw = Request.QueryString["Password"].ToString();
                        authenticate(null, null);
                        break;
                }
            }
        }
        catch (ExecutionEngineException ex)
        {
        }
        if (Request.IsAuthenticated && !IsPostBack)
        {
            Response.Redirect("~/VPath/NotAuthorized.aspx");
        }
        else if (!IsPostBack)
        {
           HideTopMenu();
        }

    }
protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        Response.RedirectLocation = Request.Url.ToString();
        // bug#19156 Enter key should Login
        LoginControl.Focus();
        Page.Form.DefaultButton = ((Button)LoginControl.FindControl("LoginButton")).UniqueID;
    }