how come your using a submit button?

Topics: ASP.NET 2.0, Business Logic Layer
Jan 16, 2011 at 7:05 AM

Hey there,

I need to modify the post submission process a bit to save some additional info. I just noticed that the submit button on the admin/posts/add_entry is a regular html button and not a .net button and you're using some javascript to actually save the post. Just wondering what the reason was behind that instead of using .net controls?

Also, I'm looking through the source code now to figure out where i need to make changes to allow me to add some additional fields to the post. Could you tell me where I should look for that? I'm not doing anything fancy - just going to add a few extra form fields to the new post (and edit post) screen to save some additional text. The code for saving/updating looks pretty intense. Hopefully i'll find it myself. but if i don't i'd appreciate any pointers.


Jan 16, 2011 at 7:16 AM

It's an AJAX post to the server.  It's pretty easy to add additional fields.

In Add_Entry.aspx, the data being sent is prepared here:

var dto = {
	"id": Querystring('id'),
	"content": content,
	"title": title,
	"desc": desc,
	"slug": slug,
	"tags": tags,
	"author": author,
	"isPublished": isPublished,
	"hasCommentsEnabled": hasCommentsEnabled,
	"cats": cats,
	"date": date,
	"time": time

You can add additional fields to that.

The parameters you pass have to match what is received on the server.  It's received in the AjaxHelpers.aspx.cs file in the /admin folder.  In there is SavePost().  It looks like:

public static JsonResponse SavePost(
	string id,
	string content,
	string title,
	string desc,
	string slug,
	string tags,
	string author,
	bool isPublished,
	bool hasCommentsEnabled,
	string cats,
	string date,
	string time)

You can see how the fields match up on the client side and server side.  So if you add additional fields, just add them to both the client and server side.

Jan 16, 2011 at 7:59 AM

thanks - i'm digging through the code now trying to get a grasp on how the data inserts/updates work. I saw the code you mentioned above, but also looks like i would need to update the InsertPost function in dbblogproviders.cs to match the additional columns in the table. (and i assume there's an UpdatePost function as well).

I'm sure i'll be posting back here after i horribly screw up your code and need help figuring it out :)

thanks again for the help - i wish i could get this much help on commercial products