473,386 Members | 1,698 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,386 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 6944
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.