Solved

session variables and request.querytring in .net

Posted on 2014-10-30
2
144 Views
Last Modified: 2014-11-02
Usually I write in Classic ASP, but now I'm stuck with a .NET code i need to change:

<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="Pliskin.Index" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <style type="text/css">
    .ltor
    {
          direction:rtl;
          overflow:hidden;
          resize: none;
    }
    .ltor:focus
    {
          outline: none;
    }
    </style>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:Panel BackColor="#FFFFCC" runat="server" Width="410">
    <asp:TextBox BorderStyle="None" runat="server" ReadOnly="True" ID="Directions" TextMode="MultiLine" CssClass="ltor" Height="400" Width="400" Font-Size="X-Large" BackColor="#FFFFCC"></asp:TextBox>
    <br />
    <asp:TextBox ID="Username" runat="server"></asp:TextBox>
    <asp:Button runat="server" OnClick="Start" Text="Start" />
    </asp:Panel>
</asp:Content>

Now this code works - but I need it to include two additional things
1) To create a session variable -
<%session("id")=request.querystring("uid")%>

2) To put that value as the value of the "username" variable -
<asp:TextBox ID="Username" runat="server" value="<%=request.querystring("uid")%>" disable></asp:TextBox>

When I try to change it - the file don't work anymore
0
Comment
Question by:arielbf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 40414910
Please use code behind (Index.aspx.cs) page_load event:
string uid = Request.QueryString["uid"];
HttpContext.Current.Session = uid;
Username.Text = uid;

Open in new window


No need to define it in the mark up
0
 

Author Closing Comment

by:arielbf
ID: 40418856
Thank you
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question