Web Forms :: Deleting List Item / File - Writing New File With Remaining Items

Dec 23, 2010

Spent ages trying to get this right but am struggling now. I have a list box and textbox, I can happily enter Email addresses into the textbox which are saved into a text file and populated in a list box. I want to be able to select a list item and delete it, along with it's record in my text file. I was going to do it by on the delete list item / button click, it delete's the text file and then writes and a new one with the remaining list items in the list box. Unfortunately it's re-writing the file but either not including the remaining list items. Here's some examples of what I've changed and what populates the text file:

StreamWriter1.WriteLine(Addresses.Items); - System.Web.UI.WebControls.ListItemCollection
StreamWriter1.WriteLine(Addresses.Text); - A blank line?!?

The code is below. The reason I wouldn't allow the user to delete the first list item is because I thought the code was working ok but for some reason putting in a blank line to start with, and if I deleted the line it'd delete all file content. No, I don't know why I thought that either.

[Code]....

where I've gone wrong? I've not actually slept since I woke up at 8am yesterday. It's now 11am... today.

View 5 Replies


Similar Messages:

Web Forms :: Changing The Selection Color(blue) For The Items In The List Item?

Mar 3, 2011

Is there a way that we can change the color (which is defaulted to blue) when the items in the list box are selected? If so can you provide me a sample for it?

View 1 Replies

Web Forms :: List Box Is Showing More Selected Items Instead Of One Item In The Details Page?

Jun 30, 2010

I have a below control in my asp.net page (3.5 framework).

<asp:ListBox ID="OptionSelector" runat="server" SelectionMode="Multiple"
SkinID="CPList" Rows="6"></asp:ListBox>

There are 25 items in the list. I have selected one item at the time of project creation. But If I edit the project then the list box is showing more selected items instead of one item in the details page.

View 1 Replies

C# - Deleting From Repeater Item - Erroneous Deleting?

Sep 27, 2010

I have a repeater which binds a set of data. Within this repeater is a column with various controls for updating, deleting, etc. These are image buttons which fire an onclick event such as "DeleteRecord". All this does is fire a stored procedure, passing in the ID of the record to delete from the CommandArgument of the object.

This works wonderfully... except for one rather huge problem. Once you delete a record, if you refresh the page, the record where the first deleted record used to be gets deleted. For instance... if I have 4 records

1 Record1
2 Record2
3 Record3
4 Record4

and I delete record 2... The page reloads with (which is fine):

1 Record1
3 Record3
4 Record4

...if I then hit refresh...

1 Record1
4 Record4

I assume this is because the erroneously deleted object (record3) is now in the same hierarchical place as the old object used to be and .net therefore doesn't know the difference, the page refreshes and fires the onlick event, grabbing out the command argument of the new object and deletes based on the ID as obtained from the commandargument of the new object. This is obviously a huge problem, if a client did this it would destroy data erroneously and I'm at a loss here. Is there any way to stop this from happening? I'm not sure if there is a better way to go about doing things or not. If there isn't, I need some sort of way to tell the page not to execute the event or to cross reference the ID of the object that is intended for deletion against the object itself...

Code below for convenience...

EDIT Wrapped a LinkButton around it because I have some jquery code in here as well which stops the page execution to wait for user confirmation. Pressing "ok" continues page execution.

<asp:LinkButton ID="oDeleteLink" CssClass="oDeleteIcon" CommandName="Delete" CommandArgument='<%# Eval("iAccountID") %>' runat="server">
<asp:ImageButton ImageUrl="/files/system/icons/trash-steel-16.png" ToolTip="Delete This Account" AlternateText="Delete" ID="oDeleteIcon" runat="server" />
</asp:LinkButton>
protected void oAccounts_ItemCommand(Object Sender, RepeaterCommandEventArgs e) {
if (e.CommandName == "Delete") {
int ID = e.CommandArgument.ToString().Numeric();
db.SPs.SpDeleteAccount(ID).Execute();
UI.Confirm(uiBroadcast, "Account has been deleted", "300px");
BindAccounts();
}
}

View 2 Replies

Web Forms :: Error When Deleting PDF - File Is Used By Another Process

Jun 13, 2012

I have one gridview in that i have three columns "FileName"  "Open" and "Delte" if user Opens clicks on open Pdf file opens in new window that time if user clicks on Delete Button then its giving Error that "Process is using by Some one" ...

View 1 Replies

Web Forms :: Writing To Log File On First Pageload?

Oct 27, 2010

Based on this piece of code, I want to do exactly like this demonstration. However, correct me if I'm wrong but if two or more users somehow simultaneously access the web page at the same precise nanosecond in time, then wouldn't we have a race condition? So is this piece of code valid? How would I correct this to make it thread safe?

[Code]....

View 3 Replies

Web Forms :: Rollback From File Reading / Writing

Mar 9, 2011

I am using more than one files to read and write to the server. Suppose during writing or reading any of files gets error the already stored files need to be rollback or removed from storing.So that the user agin try to write without error. Simply the all of the files need to be stored into the server without error, of error occurs to any of file none of files need to be read/write

View 2 Replies

Web Forms :: Writing A File (doc) To Different Server On The Network?

May 18, 2010

I am trying to create and write a file on a remote server using the below code:

[Code]....

but i am running into issues and getting errors. Below are some tries i have given. My IIS settings are 'Anonymous Access' checked and also 'Integrated windows authentication' checked.

a. As i understand asp.net site would run using ASPNET account, i tried giving full permission to ASPNET account to the folder on the remote server (where i want to drop the file). But i am getting this error - "Logon failure: unknown user name or bad password"

b. The other thing i tried is giving full permissions to 'Everyone' to the remote server folder. But i get the same error as above. But when in my web.config i enable impersonation by using:
[Code]....

then the error goes away and everything works fine as expected. The file gets dropped to the network share.

why the scenario (a) doesn't work because that should work as if i give ASPNET account full access to the folder, and my website is running under the same account, then it should work.

Also, in the scenario (b), i believe it is using my domain account, as the impersonation is true without specifying any username and password and also the remote server folder has Everyone access to full control.
BUT, as a security breach, i cannot use Everyone account to the remote folder. In that case, how can i make this working.

I was also thinking if i can use the virtual directory as the path to the remote folder, something like
http://domain.com/remotefolder but dont know how can i use this approach. Can someone pls share some sample code and the configuration.

View 1 Replies

Web Forms :: Writing Bitmap File On Server?

Oct 19, 2010

I'm making an application which takes image from user upload it to server and then perform any image processing like to convert to gray or invert etc.

My problem is this when i did the process on image to gray it or invert then how to write this new file on server or is there any other way so that i would be able to show this (new) image to user and make it downloadable?

View 2 Replies

Web Forms :: File Reading And Writing For Number Of User

Mar 16, 2011

In my application i want to share one .txt for read and write among no. of users. in Button click i m writing data in that file and in tick event of Timer i m reading that file, In tick event i m reading that file based on file based cachin means if file have been changed then only i m reading that file but when i have put m application i IIS then i m not able to get updated file.

View 2 Replies

Web Forms :: Writing A Log In Xml File Or Insert Query In Database?

Feb 20, 2010

i want to maintain a log of the visitors for a website.. the number of visitors is fix approximate (800), but i have to maintain the record of each visit page wise like page Id, time visited, user id. i am doing it using a database as it was .

i was asked to use a insert query on every page ,(ie each time user visits a page write the log to database), but i dint like the idea.. of making server trips every time the user visits a page and also we have a seperate database server. I had a idea of using XML.. but which is the best way performance wise writing a log in Xml file or insert query in database?

View 4 Replies

Web Forms :: Writing To A Text File Upon Application Login

Aug 24, 2010

I have the following subroutine in an asp.net application class. The subroutine writes data to a text file upon application login. My question is that if this function was called at the same time by two different users would it cause any kind of error. Is there a need for a try catch?

Public Shared Sub writeToLogFile(ByVal UserName As String)
Dim strLogMessage As String = String.Empty
Dim strLogFile As String = System.Web.HttpContext.Current.Server.MapPath("~/Log.txt") Dim swLog As StreamWriter
strLogMessage = DateTime.Now.ToShortDateString().ToString() " ==> " & UserName
If Not File.Exists(strLogFile) Then
swLog = New StreamWriter(strLogFile)
Else
swLog = File.AppendText(strLogFile)
End If
swLog.WriteLine(strLogMessage)
swLog.WriteLine()
swLog.Close()
End Sub

View 5 Replies

Web Forms :: Writing Metadata To File Error On Build?

Jun 29, 2010

I keep getting this error when trying to Run or Build my ASP Project. A few details:

I migrated this project from VS 2003 to VS 2008 (C#) It works fine when I successfully compiled it and deployed onto server.I have Plenty of free diskspace available.I have 4 GB Ram and Windows XP So each time I try to build this project, I get the following error.

Error 57
Unexpected error writing metadata to file 'C:InetpubwwwrootProject.IntranetobjTestProject.Intranet.dll' -- 'Not enough storage is available to complete this operation. 'Project.Intranet

View 1 Replies

VB File Not Recognizing Items From ASPX File

Jun 22, 2012

I am having an issue where if I add something to an aspx file, such as adding "<asp:HyperLink ID="HyperLink1"...", the item is not recognized in the associated vb file and I get "Name 'HyperLInk1' is not declared". Nothing I've tried seems to work, and the only way I can get it to work is to delete the files from the project, then re-add them back in as a new web form. Then it works.

why this is happening, and how I get it to recognize when I add things to an asp file? Of course I save the files and rebuild the web site, and that doesn't work.

FYI, my header in the aspx file looks like this:

Code:

%@ Page Title="" Language="VB" MasterPageFile="~/Frame.Master" AutoEventWireup="false" CodeFile="Reporting.aspx.vb" Inherits="Reporting_Reporting" %>

And the associated vb file is named Reporting.aspx.vb, and the start looks like this:

Code:
Partial Class Reporting_Reporting
Inherits System.Web.UI.Page

View 3 Replies

Web Forms :: Writing Text To File With Open Or Save Dialog Box?

Mar 29, 2010

i trying to write some text to a file in browser system......for this i'm using stream writer as like this

StreamWriter sw = new StreamWriter("c:/Billing report.doc");

but wat i need is browser should open a dialog box and ask open or save.

View 7 Replies

Web Forms :: Writing A Custom Class For A Single File Uploader?

Oct 21, 2010

I'm fairly new at writing c# with asp.net and thought I'd give writing a custom class for a single file uploader, but Im a bit stuck with it. I get build errors with a few of the items, here's my code:

[Code]....

View 1 Replies

Web Forms :: Access To The Path Xxx Is Denied Error When Writing XML File To Folder?

May 23, 2013

 i have a folder in soultion explore that in folder there are some xml file but when write data in c# in xml file,error Access to the path 'E:YavariTCMS-v3TCMSTCMSMDFXMLXMLFile1.xml' is denied. every i remove propertice readeonly from xml or folder that contain xml file ,next tim reade onl true

View 1 Replies

Deleting A File On The Server?

May 6, 2010

I'm trying to delete a file on the server

Try
delete("D:/xx/xx/xx.xx.uk/xxxx/documents/" & Request.QueryString("id"))
Catch ex As Exception
success.Visible = True
success.Text = "Upload Failure ERROR: " & ex.Message.ToString()
End Try

I get the error:

BC30451: Name 'delete' is not declared.

View 1 Replies

Writing To A File At Runtime

May 17, 2010

I am trying to write some lines at runtime to a text file using streamwriter, but i have to allow only 100 lines to be written to that file, if 101 line is supposed to be written to that file than first line of the file must get discarded/deleted and file must allow writing the 101 line so the file will actually always contain only 100 lines.

View 10 Replies

Writing Xml To Memory Instead Of A File?

Feb 18, 2010

Is there a way to write xml directly to an object that can represent it in memory and use that with XPath instead of an .xml file?

View 1 Replies

Web Forms :: Emtpy Source In Object Show This Message In Browser: "1 Items Remaining Waiting For..." How To No...

Jul 5, 2010

I have an object on the webpage that I normally will attach a source to. When doing that as in the code below it works fine.But if I have a empty string for setSrc1, then the webpage shows a message in the left down corner that:

"1 items remaining" Waiting for...

How would it be possible to not have this message if no src is set to the Object1 ?

[Code]....

View 3 Replies

Writing Mp4 File From Request.InputStream?

May 28, 2010

I have a page posting data to me via HTTP POST. What i want is write posted data into mp4 video format file. Here my code how to write that file:

string strFilePath = "D:\Video.mp4";
using (FileStream fs = new FileStream(strFilePath, FileMode.Create))
{
byte[] bytes = new byte[Request.InputStream.Length];
Request.InputStream.Read(bytes, 0, (int)Request.InputStream.Length);
fs.Write(bytes, 0, bytes.Length);
}

My problem is that i got the file, but it's corrupt when playback. Is there any problem with my stream or i missing some decode for mp4 file?

View 2 Replies

Use Of Writing Method As Webmethod In Cs File?

Dec 1, 2010

1.What is the use of writing method as webmethod in cs file

2.what is the use of calling webmethods through javascript file.

View 4 Replies

Writing To A File Which Can Be Password Protected?

Mar 10, 2011

i have table data which i am currently writing to an excel file, but i need to be able to securely password protect the file. Ive been told excel passwords are easy to break, so is there another file type which i can dynamically write to and password protect for emailing elsewhere (and requiring receiver to type password in to access it)?

View 2 Replies

Writing .txt File When There Is Large Amount Of Data?

Jul 22, 2010

i have write data from db to .txt file,where db have large amount data,i need to wite data into file, if some error occure, then reInitiated that file and write data again without stop process.that is Continuous calling same process

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved