I have following problem.
I have homepage with form , that have it's own logic , now I need to add a widget on this
page , what the widget should do , it's to post some Data Input from user to another aspx page.
Unfortunately I've came to ASP.NET from MVC (and have no idea how to do it in asp.net), and there I'd implement it by adding another form to page , that will post to Controller I need.
In ASP.NET I can't put another form with runat server attribute , can anyone advise the best way of implementing this task ?
Quite simple, and thanks to the magic of modelbinding not much that you have to do.
QueryString values along with id parameter in ASP.NET MVC
I (and most other's i believe, rather prefer route data (people/get/1 vs people/get?id=1)
Related
I need to change the page formatting depending on whether the page (actually a layout template) contains a form or not. Is there any way to determine this in ASP.NET MVC 4?
If I understand you well, you can use ViewBag or ViewData or Session.
For example when you page was loading, you can set ViewBag data in get method. Then you can decide in view page what you want.
Also another way, when your page loaded in javascript you can post info of your page has form. You can collect this data in Session with a special key for current page.
As a result yes we can, I hope my answer enough. If not enough, I can help you if you explain well what you want really?
I have a .NET project that needs a login form. The action of this form should take the user to the external site (Symplicity) and log them in. I've looked in to some methods (HttpWebRequest and creating a form with javascript), but being fairly new to .net, not sure they will work out for me.
What would be the best way for me to achieve this?
A form cannot be nested within an ASP.NET WebForm. You can use IFrame and within the IFrame you can host your other form.
Ultimately I have to send form post data from an iPad app to a simple ASP.NET page. Before I do that I just want to get the basic ASP.NET page working by sending a simple form post from an HTML page I have directly to the asp.net page. I post the html form to the asp.net page, and the Request.Form object is always null. I know the page is being hit, because the debugger stops on my breakpoints in the codebehind (.cs).
I know that if I sent the form post from the .aspx page it would work; that's the traditional asp.net form post model. But if the page won't process a post from an arbitrary html page then I believe it will also fail when the post comes from the ipad.
This is puzzling to me. Does ASP.NET somehow discriminate on form posts? Does it somehow know that the post didn't originate from its own aspx, and ignore the post? What is going on and how do I solve this? Thanks in advance.
Yes, ASP.NET does discriminate on form POSTs. If you set up an ASP.NET form normally and then use a tool such as Fiddler to see exactly what is being posted, then you will see all the hidden fields and values that ASP.NET requires for that page. Then, you'll be ready to send data from a non-ASP.NET source.
When posting a form in ASP.NET, it adds container information to the request form keys
For example if you have a Textbox field with an ID of: txtFullName
It could end up posting something like this: ctl00_ContentPlaceHolder1_txtFullName
This is fine if you control the page where you are posting to but if you are posting to someone else's page or API then the form keys have to be exact.
I'm looking for an example of how to post a pure HTML for via asp.net or via code in vb.net/c#
TIA
in ASP.Net 4 you have the ClientIDMode="Static" :)
but if you are still not on 4
you can use this solution:
http://www.west-wind.com/Weblog/posts/4605.aspx
but you have to be careful with it.
so just inherit the control you want like textbox and override this properties
and you should get the result you wanted.
I realize that ASP.NET is only designed to support a single form. What I am confused about is what is the appropriate method for coding multiple "forms" on a .NET page (I have a login form at the top of the page, via the Site.Master and other forms will appear on any given page). Am I supposed to respond differently? It doesn't really make a whole lot of sense. I would appreciate it if someone could clarify. Thanks.
P.S. I am currently developing on .NET 2.0 although I plan to move to .NET 3.5 soon.
Nearly all ASP.NET Web Forms post back to the same page. Unless you are working on some strange outlier (which your question doesn't indicate), you just use one form tag around the entire document, and use event hookups to your controls to handle the various instances.
For example, you can have three buttons that act as Submit buttons, one for each "form" but all inside that same form tag, and each one will call its respective event. This behavior is standard and handled by ASP.NET for you; all you have to do is write the event handlers and wire them up.
I'm not sure what you mean by a logon form. Are you doing some special ajax stuff?
You should be dividing any logical "form" as you call it into its own usercontrol.
http://www.asp101.com/lessons/usercontrols.asp
When dealing with aspx pages, think of the form on the page the same way you think of the body tag.
In that case, I would hand-code the login form at the top to submit to a separate login.aspx page. Leave the rest of the page to the other form's own purpose.
by default you can't, it's how the whole webforms technology works (MVC would probobly fix this in the newest versions).
So really it depends on what you want the "two forms" to do. For example, there's no issue with having login & search on one page, as each button has its own click event and go from there. If you wanted a second aspx page to process one of them, you could collect values and pass them through a response.redirect or some other hacky solution.