锁定三行代码 [英] lock the three lines of code

查看:113
本文介绍了锁定三行代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,先生/女士,

我想为特定用户锁定三行代码.

我正在使用他或她的登录ID和密码来检查特定的用户.

我已经使用了应用程序级别的锁定,但是即使其他用户正在使用另一种形式,使用此其他用户也会获得锁定.

我只想锁定一页.

因此可以从一个aspx.cs页面仅锁定三行代码吗?


谢谢.

Hello sir/madam,

I want to lock three lines of code for perticular user.

I''m checking for perticular user using his or her login id and password.

I have used the application level lock but using this other users also getting lock even if they are working on another form.

I want to lock only one page.

so is it possible to lock only three lines of code from one aspx.cs page ?


Thanks.

推荐答案

您可以在if块中传递此行

喜欢

如果(用户名!=您的用户名")
{
您的line1
您的line2
您的line3
}
you can pass this line in the if block

like

if (username != "yourusername")
{
your line1
your line2
your line3
}


您可以使用会话 [
You may use Session[^]
//Check weather session variable null or not
        if (Session["UserName"] != null)
        {
            //Retrieving UserName from Session
            lblWelcome.Text = "Welcome : " + Session["UserName"];
        }
        else
        {
         //Do Something else
         //Put the lines which you don't want to
}


在这里,我在上面的代码中使用了null,根据您的要求检查相应的用户名,例如if (Session["UserName"] != "User1")


Here I have used null in the above code, based on your requirement check appropriate username like if (Session["UserName"] != "User1")


这篇关于锁定三行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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