Solved

session variables and request.querytring in .net

Posted on 2014-10-30
2
135 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
2 Comments
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
Comment Utility
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
Comment Utility
Thank you
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now