Difference Between Web Page and Web Form - asp.net

I want to know the difference between Web Page and web Form

A web form produces a web page. Or many web pages. A web page is just a loose concept of a "document". A web form is a type of object which can produce web pages.

WebPage is a document / information resource that is rendered usually as HTML/XHTML on World Wide Web and is accessed through Web Browser.
Whereas, Web Form is a document where you can design and develop the Web Page, Web Form usually provides features which can enable a user to develop a Web Page.

<html>
<head>
<title>my web page</title>
</head>
<body>
<b>my web page. it does not have any html controls like textbox and button.</b>
</body>
</html>
<html>
<head>
<title>my web form</title>
</head>
<body>
<form action="mySecondPage.htm" method="post">
<b>my web form. it may contains html controls like textbox and button.</b>
<input type="text" id="txtUserName" /><br/>
<input type="submit" value="Submit User Name" />
</form>
</body>
</html>

Related

Add custom header to an iframe asp.net

There is a legacy .net application. In its content page , I need to open a MVC application. So I am using Iframe and opening the MVC application .
I am stuck as to how to send parameters to the MVC application via custom headers. I cant use query string as the paramter need to be sent is quite big.
Pls help.
<asp:Content ID="Content" ContentPlaceHolderID="MainContent" runat="server">
<iframe id="frame" ></iframe>
</asp:Content>
THis is the piece of code in my .net application. How to add headers when MVC appl is being invoked.
Don't know what you mean by passing data via "custom headers." Typically headers are for metadata, not data. If you have a significant amount of data to pass, the traditional way is via form/post. Here's one way to do it:
In the legacy app (the one that contains the iFrame):
<asp:Content ID="Content" ContentPlaceHolderID="MainContent" runat="server">
<iframe id="frame" src="https://MyLegacyApp.com/Handoff.aspx"></iframe>
</asp:Content>
Note: Yes, the SRC of the iFrame points to the legacy app, not the new MVC app.
Add a new page to the legacy app called Handoff.aspx that looks like this:
<!-- Provide image while form is posting. Style = centered. -->
<IMG SRC="Spinner.png" ALT="Please wait" style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);">
<!-- Hidden form that will post data to MVC site -->
<FORM Action="https://MyMVCApp.com/ReceiveHandoff" method="POST">
<INPUT Name="Input1" Type="Hidden" Value="PLACE YOUR HUGE DATA HERE, OR IN SEVERAL HIDDEN TAGS IF YOU WANT.">
</FORM>
<!-- Script that autoposts the form -->
<SCRIPT>
window.onload = function(){document.forms[0].submit();}
</SCRIPT>
Now the "ReceiveHandoff" page in your MVC site will be accessed via iFrame and initialized with the data passed in the form. To read the data, you can use one of these methods, for example:
var data = Request["Input1"];

SItecore Field renderer not working in page editor

Field renderer was working fine on mvc but now we moved to web pages, and i am converting my layouts & renderings to webpages but field renderer are not working in page editor mode but in published mode looking fine. page editor screen shot is attached.
Field rendered as
<sc:Text ID="Title" Item="<%# ((Sitecore.Data.Items.Item)Container.DataItem) %>" Field="Navigation Title" runat="server" />
and
<%# FieldRenderer.Render(Container.DataItem as Sitecore.Data.Items.Item, "Navigation Title") %>
tryied both but same result :) any help would be appreciated.
I have av vague memory of seeing this error before. If I remember right, the problem was that Sitecore couldn't do all its Page Editor magic properly by inserting scripts etc into the html header and body. It's worth I try to just verify that your layout forms a proper html document and having the head and a form accessible from the server, such as this:
<!DOCTYPE html>
<html>
<head runat="server">
</head>
<body>
<form runat="server">
</form>
</body>
</html>
I was a long time ago I used webforms with Sitecore, so I don't remember exactly what components Sitecore hooks into in order to make the editor works, but having a page structure as above should be good to go.
Hope it helps
// Mikael

https Request for CSS file gives 502 Bad Gateway

recently, I had to add some of my website pages to secure pages by installing SSL. My problem arises when I make a call to a secured web page https://www.myDomain.com/test/httpstest.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="https://www.myDomain.com/test/Style/Secure/en/BodyStyle.css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<div>
Test Https
</div>
</form>
</body>
</html>
at this point when calling the page the CSS gives the below response
noting that the SSL Settings on the Test folder is set to Accept in the IIS 7
how can I fix this and get the CSS file called over https normally ?
try calling your css by just
<link href="./test/Style/Secure/en/BodyStyle.css" rel="stylesheet" />
When you are using https, it binds it to your whole entire domain name.
If want your css3 to be hidden from the rest the public, this is impossible when you are importing through html. Browsers need this file to render ur html designs properly.

Request.Form ASP not Working

This feels like a very stupid question, but I've been trying and searching for hours and can't figure out the problem. I'm new to pretty much all web development, and this was a test to figure out how to access form data on a new page. It just will not work for me. I have contactus.html and contactusaction.asp saved in the same folder on my desktop. Clicking submit loads contactusaction.asp, but "fname" will not appear on the next page no matter what I try. I've even copy and pasted other people's request.form examples, and I still have yet to get the comand to work in any way.
contactus.html:
<html>
<head>
Hello
</head>
<body>
<form method="post" action="contactusaction.asp"/>
<input type="text" name="fname"/>
<input type="submit" value="Submit"/>
</form>
</body>
</html>
contactusaction.asp:
<html>
<head>Hello:</head>
<body>
<%
Dim x
x=Request.Form("fname")
Response.Write(x)
%>
</body>
</html>
Silly question, but after reading "saved in the same folder on my desktop" I have to ask - are you testing this using IIS or some other web server software on your desktop?
If you're just opening the local HTML page directly (double-clicking on the file vs running a local IIS and going to http://localhost/ or however you have it set up), there's no server running the actual ASP/VBScript code.
Also, reguardless of the answer to the above question, you should definitely fix the <form> tag as Guido Gautier mentions in his comment to your question.
This:
<form method="post" action="contactusaction.asp"/>
Should be this:
<form method="post" action="contactusaction.asp">

Issues with aspnetForm in hybrid asp.net webforms/mvc app

I am building a hybrid MVC/Webforms application where my MVC views are using an asp.net webforms 2 MasterPage. Everything has been working perfectly until I decided to put a form in my MVC view. Since ASP.NET Webforms wraps the entire page in a form element and you can't have a form within a form, I'm a little bit stuck.
There are a load of legacy controls in the master page which rely on the post back so I can't just disable it. The one thought I have at the moment is that all of the controls which rely on the aspnetForm form are above of the MVC page so was wondering if there is anyway to control when asp.net closes the aspnetForm form tag? Or does anyone have any other thoughts about how I could solve this problem?
I've been here before, and ended up plumping for separate master pages, however:
Maybe you haven't looked too closely, but you do have control over where and how that form is wrapped around your entire container
[Edit]: More complete example:
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="LegacyContentHolder" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
<asp:ContentPlaceHolder ID="MvcContentPlaceHolder" runat="server">
</asp:ContentPlaceHolder>
</body>
Surely you can just move that around the appropriate placeholders for the Webforms stuff, and leave the other placeholders outside the scope of it?
This generates the following markup if used on a page
<body>
<form name="aspnetForm" method="post" action="Test.aspx" id="aspnetForm">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNDMyNDU0NjAzZGT01Ocz+ON8w56SI8x7nj2/h8B/4g==" />
</div>
<div>
Web forms behaviour has been generated here, boo
</div>
</form>
MVC content has been generated here, yay
</body>
[Edit]
Note: I've checked our code now, had to go back a few versions - what we also did is had three master pages, one for the skeleton described above, one with the specific ASP.NET Webforms stuff, and one inheriting from that for just the MVC stuff.
Kept things kinda clean, and ready for migrating it away from Webforms in the future.
You shouldn't have a problem, you control where the form tag is in your masterpage. Are you saying to need to close the masterpage's form tag early when using it for MVC, and leave it where it is for WebForms?
You'll probably need to mess about with the control tree, when I've done this before I've used two masters, although you might be able to get away with abstracting a common base.master, then have mvc.master and webforms.master

Resources