473,320 Members | 1,838 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,320 software developers and data experts.

Confirmation of delete c#

Hello all,

I don't know c# that well and thus need urget help. I have a page that
displays files from an access database that has a button to be delet file
from database. I need a confirmation box to make sure the user wants to
delet the file. Here is my code:
private string GetFilesFromAccessDb()

{

StringBuilder buffer = new StringBuilder(1024);

buffer.Append("<table align=\"center\" width=\"95%\" border=\"0\"
cellspacing=\"2\" cellpadding=\"2\">");

buffer.Append("<tr><td width=\"40%\"><span
class=\"dimColor\">Name</span></td>");

buffer.Append("<td width=\"20%\" align=\"center\"><span
class=\"dimColor\">Size</span></td>");

buffer.Append("<td width=\"40%\" align=\"center\"><span
class=\"dimColor\">Content Type</span></td></tr>");
using(OleDbConnection con = new OleDbConnection(ConnectionString))

using(OleDbCommand cmd = new OleDbCommand(CmdText, con))

{

con.Open();

OleDbDataReader rd = cmd.ExecuteReader(CommandBehavior.SingleResult |
CommandBehavior.CloseConnection);

while(rd.Read())

{

int fileId;

string fileName;

int fileLength;

string contentType;

fileId = rd.GetInt32(0);

fileName = rd.GetString(1);

fileLength = rd.GetInt32(2);

contentType = rd.GetString(3);

buffer.Append("<tr><td><a href=\"file.aspx?file_id=");

buffer.Append(fileId);

buffer.Append("&mode=view\">");

buffer.Append(fileName);

buffer.Append("</a>");

buffer.Append("</a> [ <a href=\"file.aspx?file_id=");

buffer.Append(fileId);

buffer.Append("&mode=delete\"><font color = red>Del</a></font> ]");

buffer.Append(" [<a href=\"file.aspx?file_id=");

buffer.Append(fileId);

buffer.Append("&mode=download\"><font color = green>Dnld</a></font> ]");

//buffer.Append("<INPUT TYPE = BUTTON NAME = dnldButton VALUE = download
onClick)";

//buffer.Append("<INPUT TYPE = BUTTON NAME = delButton VALUE = Delete>");

buffer.Append("</td><td align=\"center\">");

buffer.Append(fileLength);

buffer.Append("</td><td align=\"center\">");

buffer.Append(contentType);

buffer.Append("</td></tr>");
}

rd.Close();

buffer.Append("</table>");

}

return buffer.ToString();

}

How do i do this?

cheers

Jul 21 '05 #1
2 6939
John,

Are you using ASP.NET? It seems you are trying to generate web pages
dynamically by your StringBuilder which is unnecessary. The ideal way to do
this is to use the VS.NET to design (draw) a page and inside page you can use
controls and maybe you can bind those controls to your data source. You can
also call your C# function inside the aspx file by the tag like <% %> or <%
=something() %>.

In your case, if you want to confirm something with users, you can create a
page contains a button or something and handle the postback; or you can write
some javascript in your client code and pop up a dialog box directly from
user's browser to ask users.

Let me know if you need further help.

"John Smith" wrote:
Hello all,

I don't know c# that well and thus need urget help. I have a page that
displays files from an access database that has a button to be delet file
from database. I need a confirmation box to make sure the user wants to
delet the file. Here is my code:
private string GetFilesFromAccessDb()

{

StringBuilder buffer = new StringBuilder(1024);

buffer.Append("<table align=\"center\" width=\"95%\" border=\"0\"
cellspacing=\"2\" cellpadding=\"2\">");

buffer.Append("<tr><td width=\"40%\"><span
class=\"dimColor\">Name</span></td>");

buffer.Append("<td width=\"20%\" align=\"center\"><span
class=\"dimColor\">Size</span></td>");

buffer.Append("<td width=\"40%\" align=\"center\"><span
class=\"dimColor\">Content Type</span></td></tr>");
using(OleDbConnection con = new OleDbConnection(ConnectionString))

using(OleDbCommand cmd = new OleDbCommand(CmdText, con))

{

con.Open();

OleDbDataReader rd = cmd.ExecuteReader(CommandBehavior.SingleResult |
CommandBehavior.CloseConnection);

while(rd.Read())

{

int fileId;

string fileName;

int fileLength;

string contentType;

fileId = rd.GetInt32(0);

fileName = rd.GetString(1);

fileLength = rd.GetInt32(2);

contentType = rd.GetString(3);

buffer.Append("<tr><td><a href=\"file.aspx?file_id=");

buffer.Append(fileId);

buffer.Append("&mode=view\">");

buffer.Append(fileName);

buffer.Append("</a>");

buffer.Append("</a> [ <a href=\"file.aspx?file_id=");

buffer.Append(fileId);

buffer.Append("&mode=delete\"><font color = red>Del</a></font> ]");

buffer.Append(" [<a href=\"file.aspx?file_id=");

buffer.Append(fileId);

buffer.Append("&mode=download\"><font color = green>Dnld</a></font> ]");

//buffer.Append("<INPUT TYPE = BUTTON NAME = dnldButton VALUE = download
onClick)";

//buffer.Append("<INPUT TYPE = BUTTON NAME = delButton VALUE = Delete>");

buffer.Append("</td><td align=\"center\">");

buffer.Append(fileLength);

buffer.Append("</td><td align=\"center\">");

buffer.Append(contentType);

buffer.Append("</td></tr>");
}

rd.Close();

buffer.Append("</table>");

}

return buffer.ToString();

}

How do i do this?

cheers

Jul 21 '05 #2
I am using this code off a freely available source. I do not know c# very
well, but udnerstandd what you mean. Is there anyway to do in its current
form?
cheers
"Yang Lu" <Ya****@discussions.microsoft.com> wrote in message
news:4C**********************************@microsof t.com...
John,

Are you using ASP.NET? It seems you are trying to generate web pages
dynamically by your StringBuilder which is unnecessary. The ideal way to
do
this is to use the VS.NET to design (draw) a page and inside page you can
use
controls and maybe you can bind those controls to your data source. You
can
also call your C# function inside the aspx file by the tag like <% %> or
<%
=something() %>.

In your case, if you want to confirm something with users, you can create
a
page contains a button or something and handle the postback; or you can
write
some javascript in your client code and pop up a dialog box directly from
user's browser to ask users.

Let me know if you need further help.

"John Smith" wrote:
Hello all,

I don't know c# that well and thus need urget help. I have a page that
displays files from an access database that has a button to be delet file
from database. I need a confirmation box to make sure the user wants to
delet the file. Here is my code:
private string GetFilesFromAccessDb()

{

StringBuilder buffer = new StringBuilder(1024);

buffer.Append("<table align=\"center\" width=\"95%\" border=\"0\"
cellspacing=\"2\" cellpadding=\"2\">");

buffer.Append("<tr><td width=\"40%\"><span
class=\"dimColor\">Name</span></td>");

buffer.Append("<td width=\"20%\" align=\"center\"><span
class=\"dimColor\">Size</span></td>");

buffer.Append("<td width=\"40%\" align=\"center\"><span
class=\"dimColor\">Content Type</span></td></tr>");
using(OleDbConnection con = new OleDbConnection(ConnectionString))

using(OleDbCommand cmd = new OleDbCommand(CmdText, con))

{

con.Open();

OleDbDataReader rd = cmd.ExecuteReader(CommandBehavior.SingleResult |
CommandBehavior.CloseConnection);

while(rd.Read())

{

int fileId;

string fileName;

int fileLength;

string contentType;

fileId = rd.GetInt32(0);

fileName = rd.GetString(1);

fileLength = rd.GetInt32(2);

contentType = rd.GetString(3);

buffer.Append("<tr><td><a href=\"file.aspx?file_id=");

buffer.Append(fileId);

buffer.Append("&mode=view\">");

buffer.Append(fileName);

buffer.Append("</a>");

buffer.Append("</a> [ <a href=\"file.aspx?file_id=");

buffer.Append(fileId);

buffer.Append("&mode=delete\"><font color = red>Del</a></font> ]");

buffer.Append(" [<a href=\"file.aspx?file_id=");

buffer.Append(fileId);

buffer.Append("&mode=download\"><font color = green>Dnld</a></font> ]");

//buffer.Append("<INPUT TYPE = BUTTON NAME = dnldButton VALUE = download
onClick)";

//buffer.Append("<INPUT TYPE = BUTTON NAME = delButton VALUE = Delete>");

buffer.Append("</td><td align=\"center\">");

buffer.Append(fileLength);

buffer.Append("</td><td align=\"center\">");

buffer.Append(contentType);

buffer.Append("</td></tr>");
}

rd.Close();

buffer.Append("</table>");

}

return buffer.ToString();

}

How do i do this?

cheers

Jul 21 '05 #3

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

Similar topics

3
by: Dennis Allen | last post by:
Hi. On my online ordering form I use browser cookies to keep track of user items. My confirmation page reads: "If any of this information is incorrect, please go back to the order form and...
6
by: Dotnet Guy | last post by:
I want to add a confirmation dialog box before I delete the records in my form. I have a piece of javascript code in html that checks for confirmation. But the main issue lies in calling this...
1
by: Grey | last post by:
I can used the RegisterOnSubmitStatement to set the confirmation alert box, i.e. RegisterOnSubmitStatement("submit", "return confirm('Delete Page?');"). But this confirmation box prompted out from...
3
by: vcornjamb | last post by:
Hello, I am developing a web form that contains some buttons and a data grid which has as its last column link buttons that will delete the data associated with that row. Everything works fine,...
4
by: DrData | last post by:
I'm working on an ASP.Net application written in C#. On one page, there are several datagrid controls used to display, edit and delete detail records relating to the master record also displayed on...
1
by: Amelyan | last post by:
What is the common way in ASP.NET C# to pop up a confirmation dialog box? E.g. Are you sure you want to delete this item? Yes No
0
by: Elton W | last post by:
Hi Peter, You use DeleteButton.Attributes.Add("onclick", "return confirm ('Are you sure you want to delete?');"); in datagrid_ItemDataBound event to add confirmation for delete button.
0
by: Suzanne | last post by:
I'd like to know how can I put up a confirmation question when the user tries to delete a row in the datagrid by clicking on the row header and pressing the Delete key? I have found this code on...
0
by: johnmott | last post by:
Hi all, One of the limitations of the GridView control is that the built-in delete processing doesn't prompt for confirmation -- something thats very important for a user interface. True, you...
4
by: ITCraze | last post by:
Hello everyone, I have a Gridview , whose first column is template colums which contains checkboxes , outside my GridView I a have a delete button. So in this application,when the user check...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
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...
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)...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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

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.