Solved

2 buttons, add and remove to append to and delete from file in aspx page.

Posted on 2014-01-25
1
297 Views
Last Modified: 2014-02-11
Hi;

I have 2 buttons, add and remove to append to and delete line (value in textbox) from file in aspx page respectively.

The thing is that I got in the point that the contents of the file must be loaded if it's not postback (first load) to a dropdown.

Is there a sample feasible algorithm for this? or a pseudocode? or the code? (I have to check file's existency or whether it's empty or not to be free of exceptions)

Kind regards.
0
Comment
Question by:jazzIIIlove
1 Comment
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 500 total points
Comment Utility
You can use Page.IsPostback property is true or not. If not true then check whether file exists or not using File.Exists(filename). If exists then read the  file content File.ReadToEnd() , it will return string. If the string is not empty then use in your application. Psuedocode goes like given below.


if(!Page.IsPostback)
{

   if(File.Exists("yourfilegoeshere")
  {

    string content = File.ReadToEnd("yourfilegoeshere")
    if(content.Trim() != string.Empty)
    //has content use it. 

  }
}

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now