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
Solved

session variables and request.querytring in .net

Posted on 2014-10-30
2
141 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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

840 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