473,406 Members | 2,745 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,406 software developers and data experts.

Control design

Hi,
I'm just having a few problems working through the design of some
controls. Basically i want to have link (linkbutton etc) that will do
postback, in my case do a delete, but it needs your standard ID (the
primary key in the db). The way i'm doing it now is:

url link to same page:
page.aspx?command=delete&id=123

eg. return to the same page it's on
and have a method that captues this and does the delete
eg.
string isDelete = Request.Params["command"];
if(isDelete=="Delete")
{
string id = Request.Params["Room"];
doDelete(id);
}
It works, but seems a bad way to do it in terms of asp.net where other
controls do postback without such work-arounds.

The main problem i can't understand is the url in a repeater control

<asp:Repeater id="myreater" runat="server">
<ItemTemplate>
<a href="page.aspx?do=delete&id=<%#DataBinder.Eval(Co ntainer.DataItem,
"Notice_text")%>" > Delete something </a>
</ItemTemplate>
</asp:Repeater>
How would i get the individual id of the item from that link button
like in a onClick event in a datagrid control.
I'd like to just have a linkbutton that has an onClick even that takes
the id and deletes that item within the same page.
Would i have to create my own control?

Any help would be most appreciated,
thanks
Nov 18 '05 #1
5 1664

Hi Mark,

You can use the OnItemCommand of the repeater. Check the url below for an
example;

http://msdn.microsoft.com/library/de...mmandtopic.asp

You can also do the same with a datagrid, and you would have more options.

Hope this helps,

Ethem Azun

"Mark" wrote:
Hi,
I'm just having a few problems working through the design of some
controls. Basically i want to have link (linkbutton etc) that will do
postback, in my case do a delete, but it needs your standard ID (the
primary key in the db). The way i'm doing it now is:

url link to same page:
page.aspx?command=delete&id=123

eg. return to the same page it's on
and have a method that captues this and does the delete
eg.
string isDelete = Request.Params["command"];
if(isDelete=="Delete")
{
string id = Request.Params["Room"];
doDelete(id);
}
It works, but seems a bad way to do it in terms of asp.net where other
controls do postback without such work-arounds.

The main problem i can't understand is the url in a repeater control

<asp:Repeater id="myreater" runat="server">
<ItemTemplate>
<a href="page.aspx?do=delete&id=<%#DataBinder.Eval(Co ntainer.DataItem,
"Notice_text")%>" > Delete something </a>
</ItemTemplate>
</asp:Repeater>
How would i get the individual id of the item from that link button
like in a onClick event in a datagrid control.
I'd like to just have a linkbutton that has an onClick even that takes
the id and deletes that item within the same page.
Would i have to create my own control?

Any help would be most appreciated,
thanks

Nov 18 '05 #2

Hi Mark,

You can use the OnItemCommand of the repeater. Check the url below for an
example;

http://msdn.microsoft.com/library/de...mmandtopic.asp

You can also do the same with a datagrid, and you would have more options.

Hope this helps,

Ethem Azun

"Mark" wrote:
Hi,
I'm just having a few problems working through the design of some
controls. Basically i want to have link (linkbutton etc) that will do
postback, in my case do a delete, but it needs your standard ID (the
primary key in the db). The way i'm doing it now is:

url link to same page:
page.aspx?command=delete&id=123

eg. return to the same page it's on
and have a method that captues this and does the delete
eg.
string isDelete = Request.Params["command"];
if(isDelete=="Delete")
{
string id = Request.Params["Room"];
doDelete(id);
}
It works, but seems a bad way to do it in terms of asp.net where other
controls do postback without such work-arounds.

The main problem i can't understand is the url in a repeater control

<asp:Repeater id="myreater" runat="server">
<ItemTemplate>
<a href="page.aspx?do=delete&id=<%#DataBinder.Eval(Co ntainer.DataItem,
"Notice_text")%>" > Delete something </a>
</ItemTemplate>
</asp:Repeater>
How would i get the individual id of the item from that link button
like in a onClick event in a datagrid control.
I'd like to just have a linkbutton that has an onClick even that takes
the id and deletes that item within the same page.
Would i have to create my own control?

Any help would be most appreciated,
thanks

Nov 18 '05 #3
Hi Mark,

You have more problems than you realize. Putting a command to delete a
specific record by ID into a QueryString is a major mistake. Once somebody
knows what the QueryString does, they can indiscriminately delete records in
your database by simply typing URLs into their browser!

You might want to re-think your design.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Mark" <sh**********@gmail.com> wrote in message
news:b7**************************@posting.google.c om...
Hi,
I'm just having a few problems working through the design of some
controls. Basically i want to have link (linkbutton etc) that will do
postback, in my case do a delete, but it needs your standard ID (the
primary key in the db). The way i'm doing it now is:

url link to same page:
page.aspx?command=delete&id=123

eg. return to the same page it's on
and have a method that captues this and does the delete
eg.
string isDelete = Request.Params["command"];
if(isDelete=="Delete")
{
string id = Request.Params["Room"];
doDelete(id);
}
It works, but seems a bad way to do it in terms of asp.net where other
controls do postback without such work-arounds.

The main problem i can't understand is the url in a repeater control

<asp:Repeater id="myreater" runat="server">
<ItemTemplate>
<a href="page.aspx?do=delete&id=<%#DataBinder.Eval(Co ntainer.DataItem,
"Notice_text")%>" > Delete something </a>
</ItemTemplate>
</asp:Repeater>
How would i get the individual id of the item from that link button
like in a onClick event in a datagrid control.
I'd like to just have a linkbutton that has an onClick even that takes
the id and deletes that item within the same page.
Would i have to create my own control?

Any help would be most appreciated,
thanks

Nov 18 '05 #4
Thanks for the warning, but the user can only delete things they have
permission to. A permissions check is done before the record is
erased. :D

"Kevin Spencer" <ks******@takempis.com> wrote in message news:<#o**************@TK2MSFTNGP10.phx.gbl>...
Hi Mark,

You have more problems than you realize. Putting a command to delete a
specific record by ID into a QueryString is a major mistake. Once somebody
knows what the QueryString does, they can indiscriminately delete records in
your database by simply typing URLs into their browser!

You might want to re-think your design.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Mark" <sh**********@gmail.com> wrote in message
news:b7**************************@posting.google.c om...
Hi,
I'm just having a few problems working through the design of some
controls. Basically i want to have link (linkbutton etc) that will do
postback, in my case do a delete, but it needs your standard ID (the
primary key in the db). The way i'm doing it now is:

url link to same page:
page.aspx?command=delete&id=123

eg. return to the same page it's on
and have a method that captues this and does the delete
eg.
string isDelete = Request.Params["command"];
if(isDelete=="Delete")
{
string id = Request.Params["Room"];
doDelete(id);
}
It works, but seems a bad way to do it in terms of asp.net where other
controls do postback without such work-arounds.

The main problem i can't understand is the url in a repeater control

<asp:Repeater id="myreater" runat="server">
<ItemTemplate>
<a href="page.aspx?do=delete&id=<%#DataBinder.Eval(Co ntainer.DataItem,
"Notice_text")%>" > Delete something </a>
</ItemTemplate>
</asp:Repeater>
How would i get the individual id of the item from that link button
like in a onClick event in a datagrid control.
I'd like to just have a linkbutton that has an onClick even that takes
the id and deletes that item within the same page.
Would i have to create my own control?

Any help would be most appreciated,
thanks

Nov 18 '05 #5
Thanks the idea, will research it bit. Unfortately i had to move away
from a repeater (long story involving trying to find a way of doing a
batch of stored procedures, which i couldn't work out how to do) and
was wondering if there is a way to use a linkbutton and pass the ID as
a param to the linkbutton OnClick() ?

"Ethem Azun" <Et*******@discussions.microsoft.com> wrote in message news:<38**********************************@microso ft.com>...
Hi Mark,

You can use the OnItemCommand of the repeater. Check the url below for an
example;

http://msdn.microsoft.com/library/de...mmandtopic.asp

You can also do the same with a datagrid, and you would have more options.

Hope this helps,

Ethem Azun

"Mark" wrote:
Hi,
I'm just having a few problems working through the design of some
controls. Basically i want to have link (linkbutton etc) that will do
postback, in my case do a delete, but it needs your standard ID (the
primary key in the db). The way i'm doing it now is:

url link to same page:
page.aspx?command=delete&id=123

eg. return to the same page it's on
and have a method that captues this and does the delete
eg.
string isDelete = Request.Params["command"];
if(isDelete=="Delete")
{
string id = Request.Params["Room"];
doDelete(id);
}
It works, but seems a bad way to do it in terms of asp.net where other
controls do postback without such work-arounds.

The main problem i can't understand is the url in a repeater control

<asp:Repeater id="myreater" runat="server">
<ItemTemplate>
<a href="page.aspx?do=delete&id=<%#DataBinder.Eval(Co ntainer.DataItem,
"Notice_text")%>" > Delete something </a>
</ItemTemplate>
</asp:Repeater>
How would i get the individual id of the item from that link button
like in a onClick event in a datagrid control.
I'd like to just have a linkbutton that has an onClick even that takes
the id and deletes that item within the same page.
Would i have to create my own control?

Any help would be most appreciated,
thanks

Nov 18 '05 #6

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

Similar topics

10
by: Matt Fielder | last post by:
I have developed a custom control to be used in my application. My application includes a form designer, so the control can be hosted while designmode for the control is either true or false,...
1
by: Dave | last post by:
I'm creating a composite control using Visual C#. I want to create a property for the control that will have only 3 options (txt, xml, connection). When the control is used and the property is...
2
by: Dan | last post by:
All, I have a windows form application. The form will host various user controls that will implement an interface so that was new controls can be added later without recompiling the hosting...
1
by: Robin Shaw | last post by:
Hi I'm developing a server web control and it requires a SQLConnection object. Is there a way at design time to display a list of available SQLConnection objects that have been dropped on the...
0
by: Ravi Ambros Wallau | last post by:
Hi: I've created a custom control - a grid that uses Infragistics to display some filters, the grid itself, and some buttons. Well, when using this control directly on WebForm, everything works...
1
by: Anthony Sox | last post by:
anyone know a good book or online resource on user control design in windows forms. thanks
2
by: Hexman | last post by:
Off on another journey through vb.net. What I want to do now is have a tab-control with 1 to 8 tab-pages for categories. I've read where there is not a hide method so I guess I'll have to...
4
by: forest demon | last post by:
i'm needing to create a custom entry form that needs to be reusable throughout an application framework. my first thought is to create a custom control to accomplish this. am i correct in...
1
by: indyanguy | last post by:
Hi all, I have a dashboard page that hosts several sections. Each section can have different modes (Ex: preview mode, edit mode etc) and one of the differences between the modes are how they are...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.