如何从常页中的母版页获取标签值 [英] How to get label value from master page in contant page

查看:88
本文介绍了如何从常页中的母版页获取标签值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在主页中用户登录用户名显示后,在巫婆登录或登出会话中有一个母版页。



我的问题是我有一个带评论框的内容页面我想用用户名保存评论。女巫是用户登录。



如何从内容页面的母版页获取用户名



我尝试了什么:



如何从内容页面的母版页获取用户名?

i have a master page in witch login or logout session after user login username show in master page.

my problem is i have a content page with comment box i want comment save with username. witch is user login.

how to get username from master page in content page

What I have tried:

how to get username from master page in content page?

推荐答案

标签lblMasterStatus =(标签)Master.FindControl(lblStatus);
Label lblMasterStatus = (Label)Master.FindControl("lblStatus");


根据您的问题,您想用用户名保存评论。



解决方案。



1.登录后使用会话密钥存储用户名,如Session [UserName] =LoginUsername;在会话中存储用户名后,您可以在整个页面中获取该会话的值。当您将会话用户名存储在母版页中以供显示时。



2.如果您想在子页面中获取母版页控制数据数据,那么您可以获得这样的数据。



ControlName ControlID =(ControlName)Master.FindControl(ControlID);
As per your question you want to save comment with the username.

Solution.

1. After login use a session key to store the username like Session["UserName"] = "LoginUsername"; After storing username in session you can get the value of that session throughout the page. As you are storing the session username in master page for displaying.

2. If you want to get the master page control data data in child page then u can get the data in this way.

ControlName ControlID = (ControlName)Master.FindControl("ControlID");


这篇关于如何从常页中的母版页获取标签值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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