473,322 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Enable/Disable Links

In a shopping cart app, assume that a user has placed 4 orders (each
order has a corresponding OrderID which will be unique). When he comes
to MyCart.aspx, by default, the details of his last order he had placed
will be displayed in a DataList. Also assume that the OrderID of the
last order is 13.

The details of the earlier orders placed by a particular user (when the
user places more than 1 order) can be viewed by clicking links. The no.
of links displayed will depend upon how many orders a particular user
has placed i.e. the no. of links displayed will be equal to the total
no. of orders placed by a particular user minus one. I am displaying
these links in a Repeater control.

As per the assumption that a user has placed 4 orders, to view the
details of the previous 3 orders (the details of the last order is
currently displayed to the user), 3 links will be provided to the user
immediately after the DataList. Clicking any of the links will bring
the user back to MyCart.aspx. The URL of the links will have
querystrings, UserID & OrderID, appended at the end of the URL using
which the ASPX page will retrieve records from a DB table. The text of
the links wil be just numbers starting from 1. The links will be sorted
in the ascending order of the OrderID. So in this case, the user will
see 1, 2 & 3 as the links. So for e.g. if the previous 3 OrderIDs of
UserID=15 are 4, 7 & 9, the URL of the 3 links will be

MyCart.aspx?UserID=15&OrderID=4
MyCart.aspx?UserID=15&OrderID=7
MyCart.aspx?UserID=15&OrderID=9

respectively. Clicking link '1' will display the details of OrderID=4.
Similarly, clicking link '2' & link '3' will display the details of
OrderID=7 & OrderID=9 respectively.

Suppose the user clicks link '1'. He is taken to
MyCart.aspx?UserID=15&OrderID=4 which will display the details of
OrderID=4. Under such circumstances, I want that link '1' should no
longer remain a link; it should be just plain text. Next if the user
clicks link '2', the details of the order whose OrderID=7 will be
displayed & link '2' should no longer remain a link but link '1' should
become a link (so that the user can view the details of the order whose
OrderID=4 again, if he wants to). Similarly, if the user clicks link
'3', the details of the order whose OrderID=9 will be displayed & link
'3' should no longer remain a link but link '2' should become a link
(so that the user can view the details of the order whose OrderID=7
again, if he wants to) so on & so forth.

This is where I am getting stuck. How do I enable/disable the links
depending upon which link the user has clicked? Can someone suggest me
how do I accomplish this? I don't have any problems in displaying the
order details in the DataList depending upon which link the user clicks
or in displaying the links in the Repeater. My problem lies in
enabling/disabling the links.

Note that I am retrieving the DB records using a SqlDataReader,
assigning the DataSource property of the Repeater to the SqlDataReader
& finally binding the data to the Repeater using DataBind. The Repeater
control looks like this:

<asp:Repeater ID="rptrLinks" runat="server">
<HeaderTemplate>
<table>
<tr>
</HeaderTemplate>
<ItemTemplate>
<td><a href='MyCart.aspx?UserID=<%= Request.QueryString("UserID")
%>&OrderID=<%# Container.DataItem("OrderID") %>'><%#
Container.ItemIndex + 1 %></a>&nbsp;|&nbsp;</td>
</ItemTemplate>
<FooterTemplate>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>

Oct 17 '06 #1
2 3196
well, you could determine which button was clicked and enable all but that
one..
-- assuming you give the control the same id as orderID..

foreach(Control ctrl in Page.Controls)
{
if(ctrl is LinkButton && ctrl.Id == Request.QueryString["orderID"])
{
ctrl.Enabled = false;
}
else
{
ctrl.Enabled = true;
}

}

Also make sure you are doing some security so that userID=14 cant see orders
that get passed as userID=15

"rn**@rediffmail.com" wrote:
In a shopping cart app, assume that a user has placed 4 orders (each
order has a corresponding OrderID which will be unique). When he comes
to MyCart.aspx, by default, the details of his last order he had placed
will be displayed in a DataList. Also assume that the OrderID of the
last order is 13.

The details of the earlier orders placed by a particular user (when the
user places more than 1 order) can be viewed by clicking links. The no.
of links displayed will depend upon how many orders a particular user
has placed i.e. the no. of links displayed will be equal to the total
no. of orders placed by a particular user minus one. I am displaying
these links in a Repeater control.

As per the assumption that a user has placed 4 orders, to view the
details of the previous 3 orders (the details of the last order is
currently displayed to the user), 3 links will be provided to the user
immediately after the DataList. Clicking any of the links will bring
the user back to MyCart.aspx. The URL of the links will have
querystrings, UserID & OrderID, appended at the end of the URL using
which the ASPX page will retrieve records from a DB table. The text of
the links wil be just numbers starting from 1. The links will be sorted
in the ascending order of the OrderID. So in this case, the user will
see 1, 2 & 3 as the links. So for e.g. if the previous 3 OrderIDs of
UserID=15 are 4, 7 & 9, the URL of the 3 links will be

MyCart.aspx?UserID=15&OrderID=4
MyCart.aspx?UserID=15&OrderID=7
MyCart.aspx?UserID=15&OrderID=9

respectively. Clicking link '1' will display the details of OrderID=4.
Similarly, clicking link '2' & link '3' will display the details of
OrderID=7 & OrderID=9 respectively.

Suppose the user clicks link '1'. He is taken to
MyCart.aspx?UserID=15&OrderID=4 which will display the details of
OrderID=4. Under such circumstances, I want that link '1' should no
longer remain a link; it should be just plain text. Next if the user
clicks link '2', the details of the order whose OrderID=7 will be
displayed & link '2' should no longer remain a link but link '1' should
become a link (so that the user can view the details of the order whose
OrderID=4 again, if he wants to). Similarly, if the user clicks link
'3', the details of the order whose OrderID=9 will be displayed & link
'3' should no longer remain a link but link '2' should become a link
(so that the user can view the details of the order whose OrderID=7
again, if he wants to) so on & so forth.

This is where I am getting stuck. How do I enable/disable the links
depending upon which link the user has clicked? Can someone suggest me
how do I accomplish this? I don't have any problems in displaying the
order details in the DataList depending upon which link the user clicks
or in displaying the links in the Repeater. My problem lies in
enabling/disabling the links.

Note that I am retrieving the DB records using a SqlDataReader,
assigning the DataSource property of the Repeater to the SqlDataReader
& finally binding the data to the Repeater using DataBind. The Repeater
control looks like this:

<asp:Repeater ID="rptrLinks" runat="server">
<HeaderTemplate>
<table>
<tr>
</HeaderTemplate>
<ItemTemplate>
<td><a href='MyCart.aspx?UserID=<%= Request.QueryString("UserID")
%>&OrderID=<%# Container.DataItem("OrderID") %>'><%#
Container.ItemIndex + 1 %></a| </td>
</ItemTemplate>
<FooterTemplate>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>

Oct 17 '06 #2
aiKeith, how do I set the ID attribute values of the LinkButtons within
the Repeater the same as the OrderID dynamically? I tried this:

<td><asp:LinkButton ID="<%# Container.DataItem("OrderID") %>" Text="<%#
Container.ItemIndex + 1 %>" runat="server"/>&nbsp;|&nbsp;</td>

but this generates the following error:

The server tag is not well formed.

pointing to the above <asp:LinkButton ID=....../line. What's wrong
with the <asp:LinkButton....line?

This is how I am binding data to the Repeater:

<script runat="server">
Sub Page_Load(.....)
Dim sqlReader As SqlDataReader

sqlReader = 'calling a function that returns SqlDataReader

Repeater1.DataSource = sqlReader
Repeater1.DataBind()
End Sub
</script>

Please suggest a way out. I desperately need a solution.

aiKeith wrote:
well, you could determine which button was clicked and enable all but that
one..
-- assuming you give the control the same id as orderID..

foreach(Control ctrl in Page.Controls)
{
if(ctrl is LinkButton && ctrl.Id == Request.QueryString["orderID"])
{
ctrl.Enabled = false;
}
else
{
ctrl.Enabled = true;
}

}

Also make sure you are doing some security so that userID=14 cant see orders
that get passed as userID=15

"rn**@rediffmail.com" wrote:
In a shopping cart app, assume that a user has placed 4 orders (each
order has a corresponding OrderID which will be unique). When he comes
to MyCart.aspx, by default, the details of his last order he had placed
will be displayed in a DataList. Also assume that the OrderID of the
last order is 13.

The details of the earlier orders placed by a particular user (when the
user places more than 1 order) can be viewed by clicking links. The no.
of links displayed will depend upon how many orders a particular user
has placed i.e. the no. of links displayed will be equal to the total
no. of orders placed by a particular user minus one. I am displaying
these links in a Repeater control.

As per the assumption that a user has placed 4 orders, to view the
details of the previous 3 orders (the details of the last order is
currently displayed to the user), 3 links will be provided to the user
immediately after the DataList. Clicking any of the links will bring
the user back to MyCart.aspx. The URL of the links will have
querystrings, UserID & OrderID, appended at the end of the URL using
which the ASPX page will retrieve records from a DB table. The text of
the links wil be just numbers starting from 1. The links will be sorted
in the ascending order of the OrderID. So in this case, the user will
see 1, 2 & 3 as the links. So for e.g. if the previous 3 OrderIDs of
UserID=15 are 4, 7 & 9, the URL of the 3 links will be

MyCart.aspx?UserID=15&OrderID=4
MyCart.aspx?UserID=15&OrderID=7
MyCart.aspx?UserID=15&OrderID=9

respectively. Clicking link '1' will display the details of OrderID=4.
Similarly, clicking link '2' & link '3' will display the details of
OrderID=7 & OrderID=9 respectively.

Suppose the user clicks link '1'. He is taken to
MyCart.aspx?UserID=15&OrderID=4 which will display the details of
OrderID=4. Under such circumstances, I want that link '1' should no
longer remain a link; it should be just plain text. Next if the user
clicks link '2', the details of the order whose OrderID=7 will be
displayed & link '2' should no longer remain a link but link '1' should
become a link (so that the user can view the details of the order whose
OrderID=4 again, if he wants to). Similarly, if the user clicks link
'3', the details of the order whose OrderID=9 will be displayed & link
'3' should no longer remain a link but link '2' should become a link
(so that the user can view the details of the order whose OrderID=7
again, if he wants to) so on & so forth.

This is where I am getting stuck. How do I enable/disable the links
depending upon which link the user has clicked? Can someone suggest me
how do I accomplish this? I don't have any problems in displaying the
order details in the DataList depending upon which link the user clicks
or in displaying the links in the Repeater. My problem lies in
enabling/disabling the links.

Note that I am retrieving the DB records using a SqlDataReader,
assigning the DataSource property of the Repeater to the SqlDataReader
& finally binding the data to the Repeater using DataBind. The Repeater
control looks like this:

<asp:Repeater ID="rptrLinks" runat="server">
<HeaderTemplate>
<table>
<tr>
</HeaderTemplate>
<ItemTemplate>
<td><a href='MyCart.aspx?UserID=<%= Request.QueryString("UserID")
%>&OrderID=<%# Container.DataItem("OrderID") %>'><%#
Container.ItemIndex + 1 %></a| </td>
</ItemTemplate>
<FooterTemplate>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
Oct 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: BARBARA FLOYD | last post by:
Hi, I create a popup web page using: newWin = window.open(.....) In the popup window I have href links. The popup takes a while to load and I don’t want the users to be able to click on a...
2
by: cotton_gear | last post by:
Hi, Depending on the user input I need to disbale/enable some of the links in my page. When disbled I need to display the links as normal text with cursor changed to mouse pointer style and when...
3
by: DBQueen | last post by:
I have a form with lines of controls. On some of the lines there are 3 controls (call them A,B,C); other lines have only control A. The controls have been numbered sequentially (Q20, Q21....Q76)...
0
by: talal | last post by:
How to check whether javascript is enable or disable in client browser. Remeber i can check wheter browser client support javascript with BrowserCapability class. But what if the client has disable...
8
by: rongchaua | last post by:
Hi all, i would like now to disable and enable network adapter programmatically with c#. I have searched but found nothing useful. There's no topic about this problem. Has someone done with this...
0
by: rn5a | last post by:
In a shopping cart app, assume that a user has placed 4 orders (each order has a corresponding OrderID which will be unique). When he comes to MyCart.aspx, by default, the details of his last order...
3
by: Pietro | last post by:
Hi all, First of all I'd like to thank you very very much ,as finally after many years of searching,I could find a code to disable/enable the shift key,but actually i cannot use the code as I'm...
56
by: Deepan HTML | last post by:
Hi All, Currently i am working in a framed environment where i have divided the window as 20% and 80% and the 20% is used for navigation purpose and right frame for displaying the orignal content....
2
by: Naushad | last post by:
Hi all, I am using the countinous form. I want to Enable/Disable the some fields for perticular records as per the following condition when open the form. I have written this code in "On Current...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.