Input buttons as links? - standards

Is their a case for using input buttons as page links, when your linking to the next of a series of pages of a form where your filling out information?
UPDATE - Ive inherited a site. One section is a series of pages of forms that users fill in. The 'next' link to the next page is currently an input button, not a normal link.
Is this bad from a standards / semantics point of view?

I am not sure what you exactly want. But what about, you can use the button to navigate through the pages. Just put the url address of the next page.
<form action="page_number_2.htm">
But you will need to store formulat data from every page. I mean, if the user fill the formular on one page and go to the next formular, you don't want to lose the data from the filled formular. You can stored them with php until the user will reach the final formular step, where he will klick submit-button.
Actually the link is used for navigation through the pages. But in this case, if I understand right, you need to send data from formular, if the user go to the next formular. So in this case, better to use button. Still you can make this button look like link.

It is possible to make links appear as buttons. However, in the situation you describe, it would be a bad idea. The form data will only be submitted to your server if you use a form. Allowing the user to click a link to go to the next page will cause you to lose all of the data they entered (Unless you are collecting that data via AJAX).
It is usually best to allow page element to perform the functions they were designed for to avoid confusing your users. Users expects links to work like links, and buttons to work like buttons.

Related

Asp.net controls losses the value

I am using two tabs in my page like the attached image.
.
Here, after selecting the value in all dropdownlist controls then, i click the generate button. so, the tab is moved from parameter to report. Then again i click the parameter tab. At this time all my dropdown controls shows null value.
but I want all the dropdown values which i selected before.
how can i get the dropdown control values?
It's important to remember that web pages like this are stateless. One request won't remember anything about another request.
So in your situation, you're putting in data, then it sounds like you're clicking a link (or button) that redirects you to another page, then you try and go back to the first one, and it has to fire off yet another request, with no knowledge of the first one's state.
Given that, it seems like you have two primary options (and dozens of others that I won't bother mentioning):
Move the tabs to be on the same page. (My recommendation)
There are lots of controls out there, or you could easily write one yourself, that don't separate tab pages via multiple requests. If you did that, switching tabs wouldn't lose the data.
Add a "save" button, and disable the other tab.
This way, the user actively has to save the data before being able to leave the page via another tab. The biggest issue here comes in the form of usability.
Which one of those you choose is dependent on a number of factors, not the least of which being code maintainability and the size of requests.

Cross-page posting with target _blank leaves source page unfunctional

I'm trying to describe it in as few steps as possible:
I have Page1.aspx with lot of controls, and Preview and Save button among those. I also have Page2.aspx that is the redirection target of a Preview Button click.
Since I need all the controls selections from Page1 to draw a preview on Page2 the redirection is done with setting Preview's PostBackUrl.
I also must have preview shown on a new tab or window so I used onClientClick="aspnetForm.target='_blank'" for Preview button definition.
Save button-click callback, after storing data to a database does redirection to some Page0.aspx (initial list of reports - the subject of the code)
Preview button works fine - a preview renders in a new tab, but when I go to the old tab and click on Save, I see from debugger, that firstly Page2.aspx(?) and secondly Page1.aspx are loaded. Then all the data is stored in the db, but though Page0 redirection is executed Page1.aspx stays loaded in the browser.
I have no idea what processes are behind this. Could one who knows give me an insight? Or if you consider my approach impossible to implement give some idea how to do the same?
If it's of importance, everything on the Page1 is located in an update panel.
Thank you very much for replying
In ASP.NET there are basically zero (0) circumstances in which you will ever send form data from one page to another. Although what exactly you are trying to accomplish is vague, you can consider some of the following:
Isolate unique operations/systems to a single page. If you have something like a User Profile, don't have three different aspx pages; just use a single page for the user or admin to manage that data / functions. Postback events are your friend.
Understand the difference between ViewState and traditional form data. I'm guessing that if you're trying to post form data from one page to another, you probably don't understand the point of ViewState. Using a single page to maintain temporary data that the user is currently working with is a great use for ViewState. If you want the data to appear on another page then you need to consider the data from the previous page as final and thus should be saved to a database or some other medium.
These are just some general guidelines because there is no exact answer to your problem without saying something generic like "You're doing it wrong." I would recommend starting by never again trying to post form data from one aspx page to another.

How to keep a rendered page for later usage (to resend it later)

I have an asp.net application with a search page, with criteria and result display on the same page. I want to keep a copy of the populated search page to redistribute it later to the same user, upon the button click on another page. It's kind of a "return to search" button. How can I do that?
Here is some context:
The search criteria is made up of some basic controls, and the results are then (after postback) displayed in a GridView. I also have a master page. Simple as that.
Now consider the following scenario: The user can investigate the results by clicking links that show detail pages, and can drill down over quite many detail pages with associated data. If he/she wants to get back to the search results he/she needs to click the back button of the browser quite many times.
I would like to provide a "Back to search" button on the master page that allows to return to the populated search page with one click.
Note:
I can not use the browser history in any way because it must work also when the user opened one of the detail views in another tab.
I have seen Keeping the Viewstate persistent and retrieve it on demand but it hope there is an easier solution because my grid is paginated and I have also more than one search page, where I would like to return to just the last one used.
Thanks, Marcel
I can offer some logical ways to resolve this problem, without using specialized asp.net features if they exist:
1) Is there some way to save the search string in GET request? So you can save it some way between moving through pages?
2) Another way is caching search pattern (with all filters or what you need there) somewhere - in database, for example and contain some key in get request, which would point on this pattern.

Ajax enabled search for products with multiple criteria

want to have search functionality as on this website
http://www.carwale.com/new/search.aspx#budget=6&budget=8&fuel=2
here whenever the user filters search(checks any checkbox), it updates results accordingly,
that can be understood as an ajax filter.
But at the same time, the query string also reflects for the change,
which helps the user to bookmark the filter search for later reference.
changing it through asp.net/javascript may cause the page to reload..
any hint or suggestions on implementing the same would be really helpful..
This can be done with the help of 3 things together
1) as #Aristos said, checkboxes with Auto Postback enabled
2) Ajax control toolkit Modalpopup, which gets fired automatically on every async postback (http://weblogs.asp.net/ruslan/pages/ajax-update-progress-updateprogress-in-ajax-modal-popup-modalpopupextender.aspx or http://mattberseth.com/blog/2007/07/modalpopup_as_an_ajax_progress.html)
3) History Points (http://msdn.microsoft.com/en-us/library/cc488548.aspx)
This can be done completely without the use of jQuery, if you dont want to use it.
-- For the first part, he have a set of check boxes list with autopostback.
In every post back the list is updated base on the selected check box.
All is simple until now, the cool is that is have a nice interactive interface (made with javascript and jQuery).
-- About the second part, how its change the url so can be bookmark with out reload the page. The trick here is that is place the parameters after the anchor # eg:
/new/search.aspx#budget=2
Using the anchor # the page is not reload and stay as it is. So when some one click on the check boxes, via javascript is also update the url, but only what is after the # so the page stay as is with out fully reload.
Now the parameters after the # can not read on code behind but only via javascript.
So when you have bookmark this page and you go direct to eg /new/search.aspx#budget=2 the javascript reads what is after the # and translate it to commands, check the appropriate checkboxes, and ask for refresh the content. All that can be done only via javascript.
I see that is use the jQuery history plugin as helper with this schema.
http://archive.plugins.jquery.com/project/history
The same trick with parameters after # is done from amazon, when you navigate on catalog, from page to page.
-- One more clever trick that is done is that is open a full page wait, so the user can not interact with the page until the page is ready again. If it not do that, and the user make very fast two clicks on the check boxes, then this can cause a full page post back on updatepanel and this can lose the previous settings.

How do you make a HTML page determine which Button to click (when you press the Enter key) without JavaScript?

I have an ASP.NET page with two sections on it... one for registration, one for login... each having a submit button.
When i'm in the login part of the page, i want the first 'submit' button to engage when 'Enter' is depressed. When in the registration part, i want the 2nd 'submit' button to engage when 'Enter is depressed.
Problem: I need the page to be accessible (i.e. i'm not allowed to use javascript)
Anyone got any ideas? :) :(
If the two submits are in different forms (and it sounds as if they should be in this instance) there is no issue. Any sane browser will take the submit button from the form you are in.
Wrap your controls in panels, then set the default button property of the panel to the desired button.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.panel.defaultbutton.aspx
They're in the same form... :(
Well, can you not change that? Unless they share fields, they shouldn't have to be in the same form. ‘login’ and ‘register’ sound like two different functions to me.
There is no pure-HTML way to specify a default submit button, much less different default buttons in different circumstances.
Including JavaScript does not in itself make your page inaccessible. As long as it still works with JavaScript off you're fine.
This should happen automatically, as long as the two forms are actually separate forms. In other words, there should be two separate <form> elements, one for login and one for registration.
Edit:
Browsers determine which submit button to "press" based on the form that has focus. If there are multiple submit buttons in a single form, which sounds like the case here, the browser will submit using the first submit button that it finds. I know of no way to get around that behavior.
You're really asking how to perform one of two actions with a single form, which kind of breaks the form model: a form is designed to perform an action (GET or POST) on a single URL. I can think of one way to work around this behavior, but it is not particularly clean.
Suggestion:
I made a crude drawing of what I'm talking about. You basically add two radio buttons to the top of the form, one for login and one for registration. Underneath those you have two fieldsets, one with fields for login and one with fields for registration. The form has a single submit button.
Click to view full size image http://img220.imageshack.us/img220/5923/boardc.th.jpg
Users without Javascript will check the appropriate radio button and fill in the appropriate set of fields. Users with Javascript have a better experience. If the login radio button is checked, hide the registration fieldset. If the registration radio button is checked, hide the login fieldset.
With proper styling, you can make it look nice. Your logic would have to check the radio button field's value to determine what action to take, but that shouldn't be too hard.
That's all I can come up with, given the single form limitation. This might not be a viable solution at all, depending on your other constraints, but it's all I've got. Good luck, and let me know if you have any questions about what I've discussed!

Resources