Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-01-25
1
Medium Priority
?
312 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

618 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