post asp.net form - asp.net

I have an aspx page. In tag i wrote action property to some url.
There is a submit button, when i press it the page is submitted. This is quite simple....
But what i will do when i have to submit that page to three different URLs upon pressing three different submit buttons? How would i handle the action property of tag for three different URLs. Can i submit form from server side?(I mean by changing action property of form dynamically).
I am new to asp.net please help me as soon as possible.
I will be thankful to you...

take a look at the PostBackUrl-Property as explained here:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.postbackurl.aspx

Related

Drop down list with submit

Very basic question here. I'm trying to make a simple form that includes a dropdown list and a submit button, with each dropdown item corresponding to a pdf file. The user must simply select an item and click "submit" and the file will download.
I accomplished this by adding an onClick event to the submit button. HOWEVER, WordPress strips out onClick events. How do I accomplish this in the simplest way in a WordPress site? Thank you!
The simplest method would be to hard code your form into a page template in your theme. Here is a great resource for creating custom page templates: https://www.smashingmagazine.com/2015/06/wordpress-custom-page-templates/
If the code is added to the template, then the onClick will not be stripped out.

Automatic page refresh even we navigate to another page

i have a problem in page navigating. please help me to solve out.
in one asp.net page forexample Page1.aspx i have dropdown when we select an item in dropdown that would display in a label. Then we navigate to another page from page1.aspx to page2.aspx by clicking linkbutton in page1.aspx. Again if i come to page1.aspx that previously selected value of dropdown should appear in label.
please help me.
HTTP is a stateless protocol. This means that it'll forget anything that you don't tell it to specifically ask it to.
When going back to Page1.aspx, your program has no idea what was selected before.
In terms of persisting user choices, you should look into storing them in Session ( or alternatively, cookies ) and checking for a pre-existing choice when returning to Page1.aspx.
If you have a saved value for the user at that point, you'll be able to set the correct value during the Page_Load event.
If it is like a wizard, I suggest you use a wizard control in the same page.
here is an example,
https://web.archive.org/web/20211020103244/https://www.4guysfromrolla.com/articles/061406-1.aspx

ASP.NET - RequiredFieldValidator to validate only particular controls

I have a web form. There are many different sections. I can say that each section displays data of a datatable. At each section I have OK and Cancel buttons. When I press OK any changes to the table in the database takes place. I've also put some Requiredfieldvalidators. Let's say I'm inserting a new record in the section one and the fields are correctly typed. When I press OK I get error message raised by the rest of the validators that are on the other sections. Isn't there any way that when I press OK button of a particular section to get validation errors of that same area? So what I probably need is a button that will not serve as the hole page submitter but rather a submitter of a specific section.
Place a ValidationGroup on the RequiredFieldValidator's. Then place the same ValidationGroup on the correct submit button. When its clicked, only validation controls that are a part of the group are validated.
http://msdn.microsoft.com/en-us/library/ms227424.aspx
I think janhartmann is correct ValidationGroup can help you solve the issue.Have a look at this article

injection user control depending on radio button choice (ASP.NET MVC)

I have this Create Event form (asp.net mvc), and i have to change some parts of the form, depending on user's choice. When the user clicks radio buttons, different user controls (ascx files) should be injected inside the form hopefully using Ajax. Any suggestions to do this?
If you use jQuery you can easily update your form with an ascx or partial html.
The following link could help you further
Wrap your buttons inside forms that are submitted via AJAX (Ajax.BeginForm...). Have the click event submit the form. Using Ajax.BeginForm you can specify the container to be updated with content (UpdateTargetId in the AjaxOptions). Have the form submit to a controller than returns a PartialViewResult based on the form parameters submitted (button values).
If you could have the functionality triggered by links, this is even easier. Just use Ajax.ActionLink and specify the route values necessary to get the proper content. You could, of course, style the links to look like buttons, even radio buttons though that would require some graphics, probably.

ASP.NET - Separate validation of two forms on one page?

I have what should be a fairly simple ASP.NET question, and one I thought I had found a workaround for in the past, but this time I'm having no end of bother trying to get a working solution for it.
I have an ASP.NET page with a number of input controls and a series of form validators for them. I wish the page to have separate forms where only some validators are fired by submit button A and others are fired by submit button B. An example would be a site that included a site search box with validation, and a comments section or form to fill in on the same page. When submitting comments you would not want the search validation to fire, and when running a search you would not want the comment form validators to fire.
What I need is a kind of 'validation panel', or separate form tags to enclose these sections in. Can anyone help?
You can use ValidationGroup property for this.
But don't forget, you can not have more then one form in your asp.net page.

Resources