Asp.net get value from Textbox in aspx to code behind

前端 未结 1 1910
忘掉有多难
忘掉有多难 2020-12-20 13:43

I\'m creating a login system in asp.net and C# programming language. The code behind to handle the user and password is done. But in view layer, I\'m troubling to get the va

1条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-20 14:42

    This is because these controls are parts of a template. They are not directly on the page, they are added there dynamically when Login control is initialized. To access them you need FindControl:

    string user = ((TextBox)Login1.FindControl("UserName")).Text;
    

    0 讨论(0)
提交回复
热议问题