文本框未捕获用户名 [英] Textbox not capturing username

查看:66
本文介绍了文本框未捕获用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我希望页面中的文本框在用户登录后捕获用户名.
我尝试使用下面的代码,但没有任何反应,文本框仍然为空.
有人知道这段代码有什么问题吗?
我在这里错过了什么吗?


Hi,
I want textbox in my page to capture user name after user login.
I tried using the code below,but nothing happens,the textbox is still empty.
Anyone knows what is wrong with this code?
Did i missed something here?


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web.Caching;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Project
{
    public partial class Master : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (User.Identity.IsAuthenticated)
            {
                TextBox1.Text = "Welcome " + User.Identity.Name;
            }
            else
            {
                TextBox1.Text = "Welcome user";
            }
        }

    }
}

推荐答案

与您之前询问的内容有关的问题,您不应提出新的问题.编辑您的帖子.如果文本框为空,则轨道下方的一些代码会将其设为空,否则,其中一个或另一个将位于其中.您应该在prerender事件中执行此操作,并且应该学习使用调试器,以便可以了解正在发生的情况,并告诉我们代码所采用的路径.
You should not ask a new question when this relates to what you asked before. Edit your post. If the textbox is empty, then some code further down the track is making it empty, otherwise, one or the other of these values would be in it. You should do this in the prerender event, and you should learn to use the debugger, so you could understand what is happening, and tell us what path your code is taking.


这篇关于文本框未捕获用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆