Quantcast
Channel: Code and Programming » Search Results » table
Viewing all articles
Browse latest Browse all 10

LinkButton Visual Studio

$
0
0

really need help here.Have been spending 4 hours on this.As can bee seen from the code. If username is not equals to “ADMIN”, linkbutton1 and linkbutton2 is true under the nested else statement. But the problem is when username is equals to “ADMIN”,even when i set linkbutton2,linkbutton3 to true but linkbutton1 to false,linkbutton3 is still not visible but linkbutton1 is visible.

What i want is when the username is equals to “ADMIN”, linkbutton1 should be false but linkbutton 2 and 3 is true.

Really need help….

Aspx.cs

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

public partial class shoe : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERNAME"] == null)
{
lbl_logAs.Text = “You logged in as Guest”;
LinkButton1.Visible = false;
LinkButton2.Visible = false;
}
else
{
if (Session["USERNAME"] != “ADMIN”)
{
LinkButton1.Visible = true;
LinkButton2.Visible = true;
LinkButton3.Visible = false;
}

else
{
LinkButton1.Visible = false;
LinkButton2.Visible = true;
LinkButton3.Visible = true;
}

lbl_logAs.Text = “You logged in as : ” + Session["USERNAME"].ToString();
}
}

protected void LinkButton2_Click(object sender, EventArgs e)
{
Session.Abandon();
Response.Redirect(“logout.aspx”);
}
}
________________________________________________________

***Aspx***

<%@ Page Title=”" Language=”C#” MasterPageFile=”~/MasterPage.master” AutoEventWireup=”true” CodeFile=”shoe.aspx.cs” Inherits=”shoe” %>

<asp:Content ID=”Content1″ ContentPlaceHolderID=”head” Runat=”Server”>
<style type=”text/css”>
#logas
{
padding-left:150px;
}

</style>
</asp:Content>
<asp:Content ID=”Content2″ ContentPlaceHolderID=”ContentPlaceHolder2″ Runat=”Server”>

<div id = “logas”>
<asp:Label ID=”lbl_logAs” runat=”server” ForeColor=”White”></asp:Label>

<asp:LinkButton ID=”LinkButton1″ runat=”server”
PostBackUrl=”~/accountMain.aspx” ForeColor=”Yellow”>(My Account)</asp:LinkButton>
<asp:LinkButton ID=”LinkButton3″ runat=”server” ForeColor=”Yellow”
PostBackUrl=”~/accountMain(AdminFeature).aspx”>(Admin Features)</asp:LinkButton>
<asp:LinkButton ID=”LinkButton2″ runat=”server” ForeColor=”Yellow”
onclick=”LinkButton2_Click”>(Logout?)</asp:LinkButton>
</div>
</asp:Content>

<asp:Content ID=”Content3″ ContentPlaceHolderID=”ContentPlaceHolder1″ Runat=”Server”>

<br />

<div>
<asp:SqlDataSource ID=”SqlDataSource1″ runat=”server” ConnectionString=”<%$ ConnectionStrings:shopCS %>”
SelectCommand=”SELECT [productID], [itemName], [itemPrice], [description], [imageMain] FROM [productsTable] WHERE ([categoryID] = 367)”>
</asp:SqlDataSource>
</div>

<center>
<h2 style=”width: 126px; margin-left: 99px”>SHOES</h2>
</center>
</br>

<asp:DataList ID=”DataList1″ runat=”server” DataSourceID=”SqlDataSource1″ RepeatColumns=”2″
RepeatDirection=”Horizontal” Height=”250px” Width=”880px” style=”margin-left: 125px”>
<ItemTemplate>

<asp:ImageButton ID=”ImageButton1″ runat=”server” Width=”200px” ImageUrl=’<%# Eval(“imageMain”, “Images\\{0}”) %>’ PostBackUrl=’<%# Eval(“productID”, “shoeDetailed.aspx?productID={0}”) %>’ /><br />

<asp:Label ID=”NameLabel” runat=”server” Text=’<%# Eval(“itemName”) %>’
ForeColor=”#00339


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images