I need some help about how to create document types, templates, pages or views for scenario bellow:
I have a page Search that was defined from umbraco content tree.
On that page I have a form with some textboxes fields like last name, first name... and then a button: Search.
When I press the button I wanted to go to another page and there to show the results after getting results from db.
What I did: i created a document type and template where I put the form. I moved
<form id="RunwayMasterForm" runat="server" action="" > from umbMaster.master to my new master page defined because I wanted to change action. Hoever If I change it when I load the page in browser doesn't make any difference. Umbraco still puts an action that goes to current view.
So how should I proceed? What is the best approuch when I have to execute code lines as in the case above? Isn't there any way to implement it without having to define several masterpages(where I can put code behind )?
I don't believe it is Umbraco changing the form's action, it is ASP.NET itself. There are a few ways to achieve what you want.
One way you may want to look into is setting a PostBackUrl property on the submit button itself (weird, I know) and then on your target page, you can reference the original form controls using the PreviousPageproperty --- which in my opinion is a huge hassle, but that's how it works. Or, perhaps easier, on the target page is to just reference the Request.Form collection manually, and find your posted values there.
Other options include using javascript to change the form's action attribute after the page has rendered, or---not always an option if using any other ASP.NET controls on the page or even the umbraco Edit in Canvas feature---is to remove the "runat=server" from the form tag. This will tell ASP.NET to keep its hands off this tag and leave the action alone.
Need help for logic with Umbraco and pages
Hi there,
I need some help about how to create document types, templates, pages or views for scenario bellow:
I have a page Search that was defined from umbraco content tree.
On that page I have a form with some textboxes fields like last name, first name... and then a button: Search.
When I press the button I wanted to go to another page and there to show the results after getting results from db.
What I did: i created a document type and template where I put the form. I moved
<form id="RunwayMasterForm" runat="server" action="" > from umbMaster.master to my new master page defined because I wanted to change action. Hoever If I change it when I load the page in browser doesn't make any difference. Umbraco still puts an action that goes to current view.
So how should I proceed? What is the best approuch when I have to execute code lines as in the case above? Isn't there any way to implement it without having to define several masterpages(where I can put code behind )?
Hi,
I don't believe it is Umbraco changing the form's action, it is ASP.NET itself. There are a few ways to achieve what you want.
One way you may want to look into is setting a PostBackUrl property on the submit button itself (weird, I know) and then on your target page, you can reference the original form controls using the PreviousPageproperty --- which in my opinion is a huge hassle, but that's how it works. Or, perhaps easier, on the target page is to just reference the Request.Form collection manually, and find your posted values there.
Other options include using javascript to change the form's action attribute after the page has rendered, or---not always an option if using any other ASP.NET controls on the page or even the umbraco Edit in Canvas feature---is to remove the "runat=server" from the form tag. This will tell ASP.NET to keep its hands off this tag and leave the action alone.
Here are some good MSDN articles for ya with more info... http://msdn.microsoft.com/en-us/library/ms178140.aspx ; and http://msdn.microsoft.com/en-us/library/6c3yckfw.aspx
Good luck to you!
Thanks for your reply @Funka :)
In the meaning while I found this line on a forum somewhere...
Context.Items["ActionAlreadyWritten"] = true; // this tricks umbraco into not re-writing the form's action attribute
I put that in PageLoad() and it works. Does not change action of my form.
Thanks for your help, also.
is working on a reply...