Solved

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

Posted on 2014-01-25
1
303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 500 total points
ID: 39809745
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Nadia
Suppose you use Uber application as a rider and you request a ride to go from one place to another. Your driver just arrived at the parking lot of your place. The only thing you know about the ride is the license plate number. How do you find your U…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

756 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