Validating User ID Carried Over Against Current User ID

Hello,

I working on a website  page showing our terms of agreement.  The user needs to click on a checkbox agreeing to the terms, click on the "I Accept" button,  and then they're taken to our products.  

I am trying to check whether the user ID that was carried during the navigation process is the same as the current user. If they are the same, the user should be able to keep on going forwards, otherwise, they need to go back and login again.

This is the some page code I'm using:

..
<asp:Literal runat="server" ID="UserIDLiteral" />
..

..
        <p>
            <input type="checkbox" name="TermsAgreementCheckBox" id="TermsAgreementCheckBox" />
            <label for="TermsAgreementCheckBox">I accept the terms of this agreement.</label>
            <br />
            <br />            
            <asp:ImageButton AlternateText="Launch Product" runat="server" OnClientClick="return ValidateTerms();" ImageUrl="/images/products/button-launch-product.jpg" ID="LaunchProductImageButton" CausesValidation="false" />
        </p>  
..

<script type="text/javascript">
    function ValidateTerms() {
        if ($('#TermsAgreementCheckBox').attr('checked')) {
            return true;
        }
        else {
            alert('You must accept the terms.');
            return false;
        }
    }
</script>

---

In the code behind this page,  I'm storing the original User ID value passed through the query string in the UserIDLiteral during the setHiddenFields sub:

this.UserIDLiteral.Text = string.Format(hiddenTagFormat, "userid", this.Request.QueryString["userid"].ToString());

When the user loads this page in a multiuser computer, a lot of things could happen, including another customer  logging in while this page is minimized.  What I want to do is to compare the UserID stored in the UserIDLiteral with the current user that's clicking on the checkbox and button. If they're not the same, the user needs to login again. Otherwise, they can go forwards.

I can get the current user id using this;

string currentid = this.CurrentUser.UserID.ToString()

My problem is, how and where do I do the checking process?  I have some good experience with VB.NET, but not a lot with C#.

Additionally, here's more code behind this page

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {

               this.SetHiddenFields();
                this.AddFormActionChangeJavaScript();
                this.Page.Form.Method = "post";
               
            }
        }

     
        private void AddFormActionChangeJavaScript()
        {            
            StringBuilder sb = new StringBuilder(128);
            sb.AppendLine("$(document).ready(function () { ");      
            this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Change_Form_JS", sb.ToString(), true);
        }

Thanks for all your help.

Have a good weekend.

T.
TheUndeciderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

UnifiedISCommented:
sounds like the page load would work (if not postback) for the comparison and then if it fails, do a response.redirect
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.