<%= Html.LabelFor(model => model.UserName) %>
public ActionResult EditUser(string UserName)
{
    //to do some thing
}
I have a 开发者_JAVA百科label on my .aspx page and i have a button which calls edit user button in controller. The value of username is not being passed. I am getting a null. How can I get the value?
The LabelFor helper simply generates a <label> tag whose value is never sent to the server when you submit the form. You could use a hidden field in order to include the value when the form is submitted:
<%= Html.HiddenFor(x => x.UserName) %>
Also sending the username in a GET/POST request seems like a security risk. If your site is using authentication I would recommend you fetching the username of the authenticated user from the authentication cookie.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论