I'm working on a project to syndicate library content with RSS.... and learn .NET, C#, and AJAX

Saturday, July 28, 2007

Map of controls, their panels, and their methods

I realize this is nigh illegible, but wanted to memorialize the document, which lists each control that calls methods and turns on/off panels, with separate rows for controls with conditionals. Last two pages are 'created' controls which don't appear in the initial asp. I'm not 100% sure it will help, but it can't hurt. If I can't attain one kind of persistence, this attests to another kind entirely! Dinnertime now.

Note: I did try to do this before beginning, but didn't know what needed to be in its own method. I think I could do it better from the beginning -- and would -- if I had to do it again, now that I have a bit more of an idea of the construction.

ListMaker Persistence

Earlier I mentioned that I had stuck a bunch of methods in Page_Load just to make things work, but that it didn't seem right, somehow. Also, throughout the code, I'm turning on and off panels to display the right controls.

I decided it was more elegant, albeit not ideal, to deal with all the panel manipulation and also the needed method calls on a per-control basis immediately in the Page_Load. Even if I had put all the controls into user controls, I'd still have to turn them on/off for different main control actions. NOTE: need to leave some of the panel manipulation in the control methods, for example, if it depends on the success of the operation. Might not hurt to map all controls and what should happen 1) always and 2) conditionals

Since some of my controls have auto-gen ids, such as img_btn_del, which might actually be img_btn_del1, img_btn_del2, etc., I got to use regular expressions, which is always a nice lift in the morning.

References


Friday, July 27, 2007

ListMaker Login, Logout, timeout

Today I implemented the Login, Logout, Create new account, and Timeout. Something's still not quite right about the Logout - although I am telling it to clear the session variable that says the user is logged in, it is not. But, it's thunderstorming here and I want to turn off the computer.

Next:

  1. need to add "subjects" to the Create new account routine.
  2. need to use the variables from the user table instead of the static variables I've been using - most methods will need to be updated.
  3. need to check persistence of the data about the current user.
References:

Amazon Web Services

So many awesome new technologies, so little time ...

Today I took a brief break to explore Amazon Web Services, a goldmine as far as libraries are concerned! I made my first REST request, for the item information about Cyteen, the book I'm currently reading (note: it is not about a cyborg teenager) . Basically it gets the amazon info you're used to, but in XML.

Thursday, July 26, 2007

ListMaker User Login: Begin

Today I cleaned up a lot of the debugging labels; fixed some problems I noticed.

(reloading appeared to be deleting extra items on My Lists, but actually, My Lists just wasn't refreshing until the second click so that you could see the item was deleted. I'm sure this is wrong on some level, but I added the my_lists button click to Page Load just like populate_edit_list and fill_list_display. It seems that if I make programmatically generated controls, the method that creates them needs to be in Page Load.)

(also the delete button on My Items was not working - similar problem but also with sql stmt errors)

I sketched out the user login panel, made some changes to the db tables, and began work on it. For now I am not going to worry about pw security, although I may try this approach if I get time.
Here's the login bit (whee!):

Wednesday, July 25, 2007

ListMaker Triumphant

Well, I fixed a lot of broke stuff today ... the ranking is still not beautiful, but the data in-and-out seems to be okay -- that's what took me most of the day, sadly. Now the user keeps his/her list_id on save to preserve the URL.
So, next will be

  1. re-hiding the debug labels (see below)
  2. finishing the ranking
  3. user login - this is imperative for testing by more than one user!

Persistence woes

I'm still missing something about persistence. Today (so far) was much like the Disastrous ListMaker day. Deleting items wasn't working -- my solution in place at the moment is to call fill_edit_display both in the Page_Load and at the end of the remove_Item method. (fill_edit_display just draws the pretty table and puts data in it from the dataset...)

If it's just in the Page_Load method, then when you click Remove to remove the item, neither my debug label nor the list_display update until you click another button that refreshes the page (no matter that Remove appears to refresh the page). If it's just in remove_item, then remove_item doesn't even seem to be called -- note that fill_edit_display is responsible for creating the remove_item buttons -- but how can I see them if they aren't there, hm?

delete_this, which deletes an entire list, has this characteristic as well -- that is, it calls populate_edit_list before it ends, and this is also featured in the Page_Load.

I think it must be because both remove and delete buttons are programmatically created rather than originally in the default document. It must be related to when the app actually creates the controls themselves in the lifecycle of the page. For now, I'm just glad it seems to work.

Can't sort a DataSet

You can't sort a DataSet; if you're filling the ds from one SQL query you can sort in the query ... but I have two queries and two datasets that I merge into one, so then it is not sorted. However, you can sort a DataView:

Tuesday, July 24, 2007

ListMaker ... Ranking added but currently hosed

Well ... I added the ranking interface and logic, and it should have worked. I also fixed up the problem where the List_ID was getting replaced on save, meaning the user's URL would be changing all the time (bad). But it's almost 6pm and B. has made a special dinner, and I don't really understand the error I'm getting (when I try to save list to db):

The name "LIST" is not permitted in this context.

and even before the error, the ranking wasn't saving. So I guess I'll take a look tomorrow. Most of today was spent on email anyway; also getting caught up with some JWL correspondence and marketing, and checking out Technorati.

Before I forget, the subject_id is still static - when I do the user login I need to change that.


Common errors and what they mean to me

Some .NET errors make a lot of sense. For example,

"There are more columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement."

Thank You! I know exactly what is up with that. However, others are less clear. I'm gonna start a list here of cryptic errors and the most common reasons for why they occur (at least to me). This will probably reflect *my* weaknesses as a programmer rather than anything actually related to the error : )

System.Data.SqlClient.SqlException: Incorrect syntax near '.'.
-- this means you forgot a comma in a list in the SQL statement - probably after the penultimate item.

Object reference not set to an instance of an object.
-- this means you don't even have a NULL value for something. You don't actually have the something.
-- look for variable declarations.

And finally, some error messages are just plan hi-larious:

'success' does not exist in the current context

Thanks for the zen tip!

Monday, July 23, 2007

Add JMU_Items to ListMaker

Users can now add items of their own (these are called JMU_Items after the table name, which distinguishes them from R2 items) and then add those to lists. Still to be done:
  1. the Delete Item does not work yet / again for items from lists. (@#$%) Deleting lists works fine so I should start there.
  2. So Ranking might be something to tackle, next.
  3. Then the user login.

Sunday, July 22, 2007

Harry Potter

All day. Finished. Awesome.

Thursday, July 19, 2007

ListMaker - RSS integration

Today I integrated the RSS-generator bit into ListMaker, so the user can get a RSS subscription link for any of their lists, or preview it in a new window. I had to re-validate my RSS after adding in the URL / link because of URL encoding. Also the XML needed to be not unencoded (I was XMLUnwrapping things for general purposes, but the RSS feed needed to not be unwrapped). I need to ask Bill about adding my jewel-dev database to the web server so I can upload this and test it with 'real' feed consumers...

Monday, July 16, 2007

Mandibular Bug



This was on our screen door for 3 days. It's gone today -whew!


ListMaker Update

This morning I fixed the bad "refresh" behavior and also incorporated Bill/Greg's XMLWrap and XMLUnWrap methods so that the string data is properly formatted (Amos & Andy instead of Amos ' Andy).

Next:

  • integrate the RSS-generator I wrote. Test with JMU web portal and BBoard
  • User login of some sort (this will take a bit)
  • Add panel for user to add new items to jewel and include in list (this might be tricky as then my query will have to get items from two diff tables.

Focus()

So, setting the focus was actually pretty easy! I put this in my Page_Load method:

string controlName = Request.Params.Get("__EVENTTARGET");
if (controlName == "create_lbtn") {
txt_listtitle.Focus(); }
else if (controlName.Substring(0,9) == "edit_link") { //we have many of these controls, any will do.
txt_search_rdb.Focus(); }

else { welcome_lbtn.Focus(); }

So, now the Delete button does not fire on refresh -- nor any other button. And, as it turned out, JavaScript was not even necessary!

__doPostBack and JavaScript focus

Most of the ASP.NET controls call a JavaScript function, __doPostBack, to make their magic. Today I found a nice, simple explanation about how this works...
Understanding the JavaScript __doPostBack Function?

I am working on getting the Delete button (and other buttons) not to operate when Refreshed. I'm thinking of just changing the focus() with JavaScript...

Sunday, July 15, 2007

CD Buddy

A common librarian task is to have to look up a bunch of books - maybe to check and see if the library already owns the 10-20 books that he is thinking of ordering. It sure would be handy to be able to enter several ISBNs or Titles into LEO rather than one at a time..... so this morning, I made CDBuddy for this purpose.

Something I wanted it to do was automatically do a title search on the ISBNs for which it didn't find matches (that's what I'd do!). Since it didn't find matches, it can't get them from LEO. I guess (some other time) the program could go try to find the titles from WorldCat or Amazon, and then do a title search in LEO with those titles ... but that's farther than I wanted to go : )


Saturday, July 14, 2007

Functional ListMaker

I've fixed most of what was functionally wrong with ListMaker. It now seems to be operating smoothly except that if you delete a list, then refresh the browser it will delete the next list, and so forth -- makes cleanup a breeze, but I imagine the user would not be thrilled. Next:
  1. check the data behind the scenes to make sure it's really doing what I think
  2. implement Bill/Greg's XML Encode / UnEncode (I left this out for the beginning).
  3. integrate the RSS-generator I wrote. Test with JMU web portal and BBoard
  4. User login of some sort (this will take a bit)
  5. Add panel for user to add new items to jewel and include in list (this might be tricky as then my query will have to get items from two diff tables.

If all this gets done, I'll try to get the subject-recommender part going so that the user has some suggestions to work with even before searching ... maybe get New Titles from InfoApp.

And if all THAT gets done, maybe I'll go back to PL / LEO searches and allow user to include items from these in their lists. Might finish up CDBuddy or some variant thereof, first.







Things I learned today

Before I forget ... here's stuff I learned today

  • If you want to programmatically change color, use a color method. Can't just change the property with a string.
  • Careful with char and varchar. Using char will pad your field with white spaces since it is a fixed-length field.
  • Very simple CSS buttons allow for text-only buttons that can have color, etc.

Friday, July 13, 2007

No more user control

I merged my 'list_widget' user control with the rest of the program. While this didn't solve the problems immediately, it has made it easier to fix them, which I'm doing right now. I also did go ahead and make new graphics (or the lack thereof). I'll post a pic later.

Romeo and Juliet tonight, after the Baja Bean.

Thursday, July 12, 2007

ViewState Links

Disastrous ListMaker

Polished up the CSS somewhat on Wed. morning - now functionally better -- but the new desk edge is the most eye-drawing element, and it's useless. I think I'll re-photograph my notebook on a monochrome surface, then edit out the desk entirely and use soft shades of color ... ahhh.

Most of today was spent working on data persistence (this is the "disastrous" feeling). Basically, I don't know what the status of all my page elements are at any particular time. I miss Perl. Since my working data isn't too big, I've switched from Session[] to ViewState[], but I'm not liking how this seems to work with User Controls. I made a test program with one label, one button, and a user control with its own label and button, but it seemed like everything updated everything else, which didn't make sense ... (just like my real program) ... (and yes, I did turn off the Submit Behavior of the buttons).

I did get two problems fixed:

  • Moving items from the search results to the to-be-saved list now seems to work great (I think). It was always appending, and not showing up right away. Now it works on the click, and also has the right items. The on the click is highlighted because nothing else seems to work on the first click (see below) ...
  • You can Create new lists (this had broken) and give them titles, and it sort of checks to see if there's a duplicate title. This isn't working totally perfectly, though.

Here's what's still not working:

  • deleting items from the to-be-saved list (I swear this was working before but blog says not). This has be baffled - it should be a simple onclick event, but it's not firing.
  • there are several places where the action has taken place (save list, view list to edit) but it's not showing up on the screen on the first click. It takes a second click.
  • I'm not sure that saving edited lists and saving newly created lists is really working - it looks like it is working, but I need to check the data.
The solutions to the above that I've thought of so far:
  • Getting rid of the 'user control' If I do this, it would be in the hopes of removing a layer of confusion from the ViewState. But I was so proud that I got it working, with delegates and whatnot. But, it's not really necessary.
  • Starting from scratch (ha, ha, ... no wait maybe that's a good idea...)
  • Try to learn more about View State from my test program and the books and making the current version work (yccchhhh) - the trick is how it works with user controls, though. I think I get it without the user control -Well, here's how it looks as of now... see the Edge?

DataSet vs. DataReader

For future reference ....

1. DataReaders have less overhead than DataSets and are more efficient.
2. DataReaders can be databound (i.e. to a DataGrid).

but

1. DataSets are disconnected. They are like disconnected models of the database.
2. DataSets can be made into Session objects or files, for persistence (which I need)
3. DataSets can provide access to more than one table and table relationships
4. DataSets can be bound to multiple controls and/or reiterated through multiple times whereas a DataReader is a once through.
5. You can jump to a particular record or go backwards through a DataSet.

Also, if you name your table then you don't have to worry about getting the right Table[i]!!

Tuesday, July 10, 2007

CSS / graphics for ListMaker

Well, I went ahead and tried my hand at recreating my graphics with ListMaker. I did the heading text drop shadow with CSS! It's about 50KB at the moment...

I figure if I do the CSS early, I can look out for problems with the CSS as I'm debugging other stuff (i.e. resizing browser windows). I had it almost "pretty good" but then something busted. Here's my last good build. Now, if I can just get that LH background col graphic AND the two-columns working at the same time:



Visuals for ListMaker

The other day I was pining for my inforM days at Maryland (they still have WebTrack, which I originally designed /helped populate!) and decided to work more on the ListMaker visuals. I hope that this will also spiff my CSS skillz since I will be trying to recreate my design with CSS and minimal actual graphics. Here's my initial attempt:

What the user sees upon login:


What the user sees after beginning work:

Monday, July 9, 2007

XML Documentation and Web Application vs. Web Site

I had read early on that one can document C# code with XML, and today since I was reviewing all my code and comments, thought it would be a good time to try this myself. You just use three slashes instead of two, and insert XML tags around your comments. Then Visual Studio can generate the XML file when you Build, and you can display the XML in a nice HTML page if you use an XSLT stylesheet. And if you want your nice HTML page to look like MSDN, you might check out Sandcastle, an add-in for VS to generate such pages.

Hereare some of the sites that seemed most helpful:

Before I got too far along, I realized I was missing some of the 'commands' in VS necessary to generate the XML. This is because I've got a Web Site instead of a Web Application (see Birth of ListMaker post). Which raised the question, just what is a 'Web Application' to VS? This is one of those basic questions that is hard to find information about since most folks have moved on - but, Scott Gu has an excellent introductory tutorial: Visual Studio 2005 Web Application Project Option. Also a nifty comparison chart and additional details on MSDN.

And here is one way to generate the XML doc for a .cs if you don't use the Web Application template:

>csc common.cs /doc:mydoc.xml

but, this just does the one file. In forums.asp.net, I found sample code that will do it for all the files and do it without opening the command line ... http://forums.asp.net/t/843207.aspx ...

Also, for future reference, here are other compiler options: http://msdn2.microsoft.com/en-us/library/ms379563(vs.80).aspx

Sunday, July 8, 2007

Session State in ListMaker


It's all about scope - where you are allowed to do what and to what. Spent most of this evening (and into the morning) chasing a dataset which drives the insert query for when you want to create a new list and want your items to be connected with that new list (success above!). Finally, decided to learn a little something-something about Session State with ASP.NET and this solved my DataSet problem.
Other accomplishments this evening, all in a flurry after breaking thru with Session State: ListMaker will let you Create a New List and save it. The Edit button for a list loads the items into the fill_results_display, but the delete button for each item still needs to be hooked up. If I'm a good girl, my next step will be to step back and see how I'm doing programmatically -- that is, am I following good OOP techniques? How's that documentation? But of course I want to move on with new / enhanced functionality... temptation, temptation...

Hiatus

Alex was here Thurs pm, Fri, and Sat (today). We three enjoyed new games St. Petersburg and Lost Cities. A Winter's Tale on Fri. night at Blackfriars was surprising; Dona Rosa's beforehand filled us with authentic sopes, enchiladas, and rellenos.

Today Bryan watched a STL Cardinals tripleheader but I only managed one plus 3 innings of the last one. It was a heartbreaker, with my fave Aaron Miles giving up several runs on errors and losing by 1 after Pujols hit into a double play.

Thursday, July 5, 2007

ListMaker 1.0 - new screenshots


Here's the new ListMaker home page. Rather than the old Edit pull-down, I'll just display all the lists in the opening view. Each list will have the option to delete, edit, or view the RSS output. The 'delete' works; the 'edit' and 'rss' need hooking up but the logic is sitting somewhere.

Note: I had a beastly time with "user controls" at first - not really the technology so much as figuring out the best use for a user control. You can bubble up events from user controls to the parent page, but I didn't figure out how to communicate between user controls on the same page. Then I realized I shouldn't be using user controls for what I was. As of now, I just have one user control, the widget that has two panels - one that lets you search for items and the other that displays the list-in-progress. since I can use the same structure for Create and Edit (I hope!) I made it a 'user control'.


The second image shows the "Create New List" screen which is working. Strangely enough, I didn't end up using the CSS tabs - I put 'em in and then ripped 'em out. when I decided to put the edit and create at point of need. Technically that "Welcome" is still one of the tabs - silly.



Accessible tabs with CSS

Before I lose this, here's a nifty site to use CSS with accessible navigation tabs:
http://www.sitepoint.com/article/accessible-menu-tabs

And here's another - but I didn't use this technique:
http://www.alistapart.com/articles/slidingdoors/

Also, a note here that using AJAX clearly has the potential to raise accessibility concerns. For this project, since it is a learning-by-doing, I'm going to play first, fix (if necessary) later, even though perhaps usually I would try to get it right ahead of time.

Tuesday, July 3, 2007

ListMaker - pastel version

Before the progress report, I have a design question. At the moment I have users search for items, select from them to make a temporary list, then they can save the list to the database. Since the 'lists' will one day be live, this allows the user to "work" without the public seeing the changes. But, some of today's models (Netflix) seem to be more immediate - that is, perhaps as the user chooses items, they get saved to the list immediately. In Blogger, I guess the model is that you edit, then save, which is closer to what I'm doing. So, I guess I'll stick with that. But I wonder if even the blogger edit-save model will become the immediate-save model one day.

I worked on the CSS for ListMaker today as it was getting too ugly to bear. I also removed some old placeholder controls. I'm also now using a common method to fill my dataset for "the list we're working on" and also a common method to display a dataset in a tabular format (the green box below). Right now, though, all the controls are still on all the time, and all the buttons postback so that everything is cumulative, which is wrong! I keep saying I need to separate stuff into user controls, but I don't want to leave that job in the middle so I need a chunk of time. Maybe next time.




SQL Query

Apparently I just needed a good night's sleep:

select [rdb-production].[dbo].items.item_id, [rdb-production].[dbo].items.title,
[jewel-dev].[dbo].JMU_List_Items.JMU_Lists_Items_ID
FROM [rdb-production].[dbo].Items, [jewel-dev].[dbo].JMU_List_Items
WHERE ([rdb-production].[dbo].Items.Item_ID = [jewel-dev].dbo].JMU_List_Items.Item_ID) AND
([jewel-dev].[dbo].JMU_List_Items.JMU_Lists_ID = 38)

Monday, July 2, 2007

Annual Report Day; editing with ListMaker

Most of today I worked on catching up with email and drafting annual report material. I did make a bit of progress on ListMaker's edit list feature, but need to straighten out a SQL query to get the items, lists, and the ID from the linking table (hint to self: start on line 297). After wrapping up the SQL query, however, I need to move to the overall architecture before I make too many more 'user controls' that are just stuck on the page instead of neatly filed away. Then it should go fairly quickly.

Houseguests tomorrow night and through Saturday, though, so don't expect wild flights of progress this week : )

Oh, and the AJAX accordion had to go for now because I can't see what I'm doing in design view with it in there.