PDA

View Full Version : how to post data back ...


eirikr
05-23-2010, 11:42 PM
i am writing a search engine for my project. SInce i am new to asp.net, i need some help
in fie (search.aspx)
i have two textboxes: <asp:texbox id="fromdate"...> and <asp:textbox id="todate"...>
after a form is submitted. i use a for loop to list all the date between "fromdate" and "todate" in file (search.aspx.cs).
How can i do this in file search.aspx, listing all the date under my searching form. thanks for help

Mike_O
05-24-2010, 03:22 PM
Hey eirikr,

Aside from whatever you're doing in your class (seems irrelevant to your question), by default, the values in your textboxes should automatically post pack when you submit. To be sure, put PostBack=true in your Page directive on the aspx page, and you're done.

Mike.

MewersTheCat
05-28-2010, 07:37 PM
There's lots of methods you can use to do this.. i'm personally a fan of string building and.. simply writing HTML.. but you can also build controls.

this is the way i'd do it:

I'd add a div to the form with an id and runat="server" so it can be accessed from the code behind.
<div id="myresults" runat="server"></div>

now.. in my code behind.. during the results.. i'd build an HTML table.. or just keep it simple..


for([all items])
{
if([date is between the dates]){
myresults.innerHTML += [whatever] + "<br/>";
}
}


you can get fancy and add html tables and just about anything..

if you're looking for more of a legit method of doing it.. i'd check out gridviews.. add a gridview to the form, and you can simply bind it to a datasource.. which can be.. lists, arrays.. collection classes.. blah blah.

of course the syntax on all my stuff is bad.. just.. giving examples.