Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6900955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:36:46+00:00 2026-05-27T07:36:46+00:00

I am developing a web application in ASP.NET (C#) and need to give a

  • 0

I am developing a web application in ASP.NET (C#) and need to give a user who logs in some rights (reading, writing, editing). Each right has a letter assigned to it (reading – “A”, writing – “B”, editing – “C”). In an SQL table these rights are written as a string. Aa person who can only read, has the string “A” while a person with all rights has the string “ABC”.

In a LogIn form (if login is successful) I read these rights from table and write them into a string (string myRights). Now on my master page I need to read from this string and make some panels visible and others invisible, according to the rights the user has. How can I call that string from another class?

Here is some code I am using:

public partial class LogIn : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e) 
    {
    }

    protected void btnLog_Click(object sender, EventArgs e)
    {
        string myRights = null;

        SqlConnection(ConfigurationManager.ConnectionStrings["dbConn"].ToString());
        myConnection.Open();
        try
        {
            //Password is encripted, so here is some more code that is not relevant for my problem
            SqlDataReader myReader = null;
            SqlCommand myCommand = new SqlCommand("SELECT * FROM myTable WHERE username='" + textboxUsr.Text + "' AND password='" + textboxPwd.text + "'", myConnection);

            myReader = myCommand.ExecuteReader();
            if (myReader.Read())
            {
                //There is some more code here that is not relevant to this problem
                myRights = myReader["rights"].ToString();

            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
        myConnection.Close();            
    }
}

And here is where I need to use string myRights:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    //Here is some more code, that redirects users back to Login screen if they are not loged in...

    PanelMenuRead.Visible = false;
    PanelMenuWrite.Visible = false;
    PanelMenuEdit.Visible = false;

    //HERE IS THE PART I DO NOT NOW HOW. I need to call string myRights from LogIn class
    if (myRights.IndexOf("A") != -1)
    {
        PanelMenuRead.Visible = true;
    }

    if (pravice.IndexOf("B") != -1)
    {
        PanelMenuWrite.Visible = true;
    }

    if (pravice.IndexOf("C") != -1)
    {
        PanelMenuEdit.Visible = true;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:36:47+00:00Added an answer on May 27, 2026 at 7:36 am

    You can use a session to pass data between pages. Here is a quick tutorial.

    jeroenh is right. You should definitively have a look on SQL injections as you Web site is currently vulnerable. The OWASP Web site is a good start. You can find some information on how to resolve the issue here and here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an web application using asp.net mvc, and i need to do a
We are developing an ASP.Net web application and need that application to work properly
Hi I am developing an ASP.net web application. I need to find the current
I'm developing an Asp.Net 3.5 application and I need to print some application generated
I'm developing a web application, using ASP.net and C# need to provide a functionality
We are developing secure web application using asp.net C#. After User is logged in
I'm developing a web application using ASP .NET MVC 1.0 and jQuery (including the
I'm currently developing a web application in ASP.Net with SQL Server and I would
I am developing an ASP.NET web application that incorporates google maps. I have an
I am developing a C#/SQL ASP.NET web application in VS 2008. Currently I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.