I have already read through this. However, in my case the page I am posting to is an external .aspx page.
Basically I generate XML data on the source page code with XElement, and need to POST that to an external .aspx page. The requirement say it needs to be wrapped in HTML </form> tag before posting. So my string in the code-behind file looks like
<FORM id="frmLogin" action="https://illustration.sagicorlifeusa.com/fse5/main/FormPost.aspx" method="post" target=blank>
<XML>myxml<XML\>
<input type="submit" name="__exclude__Submit" value="Run Sagicor Life Illustration Software Online ">
</form>
Now on the code-behind file, what is it that I need to do, to post this to the external .aspx page?
You can add a hidden input, set its value in codebehind and post the form to the destination page so that on that page the value can be extracted back. Did i understand your question?
That doesn't make sense. You normally don't post HTML code.
You should check the requirement for what they really want. My guess is that you would put it in an HTML tag if you post it from the browser, but that would not apply if you post it from the server.
Related
So as of right now, I'm using my _Layout.cshtml page to build the header, body and footer, and in the bodu I'm doing this in order to render my Index page:
<body class="darkDesign">
<div class="container-fluid">
#RenderBody()
</div>
</body>
And my index page is just the default one that comes with the template:
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about building Web apps with ASP.NET Core.</p>
</div>
The issue is that I want to add a class to the body tag but it won't render it because it seems as RenderBody dynamically renders the body tag for me and this is what it looks like in the DOM editor in Chrome.
How do I properly add the class to the body tag?
The problem in not Razor, as #Wiktor-Zychla mentioned, RenderBody doesn't dynamically render the body tag. (the Body in RenderBody means the page/layout content/body)
Also as I mentioned in the comment section, the <!--Loader starts--> part is not in your source (Razor), so darkDesign class removed by JS when you visit the page in the browser. as you confirmed, you should be able to see darkDesign class in body tag in page source. (in your browser hit Ctrl + U to see the page source)
So
If you using some JS library/framework (or jQuery plugin), you should check their documentation to see why they removed class from body. maybe you can disabled this behavior or tell them to add your class.
Another way (easy and dirty one) is adding the class using JS, just make sure your code execure after their code.
You can mention which library/framework (or jQuery plugin) you using, then maybe I can help you more.
I have a Website and in one webpage there is a form, where one of the fields is to upload an image. I have created in my database a column picture of type LONGBINARY. I have read some webpages where they explain how to use <asp:FileUpload ID="FileUpload1" runat="server"/>. But the doubt is that I have an input tag <input id="Submit1" type="submit" value="Put In Store" /> for my form. All the webpages where they explain about FileUpload are using a ASP button, but for my form I need an submit input.
So:
What do I do if it says I need a ASP Button but I need a submit input?
Where need to be the code of the FileUpload when you click?
My last question about FileUpload(There are the links they gave me).
You can upload a file using your way. Just in the form tag, do mention the type attribute type as multipart data. So when you click on Submit the request goes to the place that is mentioned in the action attribute of the form tag.
Example form tag:
<form action="demo_post_enctype.asp" method="post" enctype="multipart/form-data">
So.. The issue I have came across is I am migrating a client's web app to MVC2, and the original method for displaying html content is not capable of working with MVC so I am needing to update it. The functionality I need is like so: There is a side nav that will contain the actions, and say the user clicks on "FooBar" it will populate the "mainContent" placeholder with the "FooBar.html" file from a document directory. I would like to do this with no postbacks as well if it is possible. Any ideas?
You may use jQuery ajax to load the pages when user clicks on the link. load() function will be ideal here.
It is just HTML and javascript. Nothing specific to ASP.NET MVC
//Include jQuery library
<div>
<a href="Home/about" class="aLink" >About</a>
<a href="Home/FAQ" class="aLink" >FAQ</a>
<a href="Home/Contact" class="aLink" >Contact</a>
</div>
<div id="mainContent">
</div>
<script type="text/javascript">
$(function(){
$("a.aLink").click(function(e){
e.preventDefault(); // prevent the default navigation behaviour
$("#mainContent").load($(this).attr("href"));
});
});
</script>
I am doing following in one of my webpart .ascx file.
<FORM action="https://illustration.sagicorlifeusa.com/fse5/main/FormPost.aspx" id="frmLogin" method="post" target=blank>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<%= CompleteRequest %>
<input type="submit" name="__exclude__Submit" value="Run Sagicor Life Illustration Software Online" />
Notice the method="post"; However, looks like when I add this web-part, The hosting page already has a <FORM/> . How can I do the above POST?
posting to a new window from inside an ASPX web form (which SharePoint is) is tricky, because the framework wraps everything in a <form> it keeps track of. If you are required to post to the target page (i.e. get isn't good enough), you might have to:
create a separate .aspx page entirely to produce the form
open that form from within your Web Part with a JS call to window.open or an <a href="..." target="blank"
auto-post that form, with JavaScript, as soon as it loads.
(I have no firsthand experience with sharepoint; take this answer with a grain of salt.)
I'm trying to convert a classic ASP page to ASP.NET 3.5.
On the page, there is a small form to submit your e-mail address to an external newsletter site. Here's the code:
<form name="emailForm" action="http://www.site.com/emailsignup.aspx" method="get">
<input type="text" name="email" />
<input type="submit" id="btnSubmit" name="btnSubmit" />
</form>
I was hoping I'd just be able to drop this on the page and it would work, but it doesn't, it just reloads the page.
How am I supposed to do this? Does it need to be done in the code behind of the button's click event?
In ASP.Net, by default controls - like the button - that cause postbacks will submit the page back to itself EVEN if you set the action attribute on the page to another file. What you want is called Cross-Page Posting. The following MSDN pages shows you how to do this with ASP.Net 4, but there is a link at the top to get to older versions:
http://msdn.microsoft.com/en-us/library/ms178140.aspx
http://msdn.microsoft.com/en-us/library/ms178139.aspx
Otherwise you can just use the Button's Click Event Handler in the code behind.
Hope this helps.
you must be missing runat="server" in the form tag
try to create a page through the IDE and paste the code for input tags between the form tags
<input type="text" name="email" />
<input type="submit" id="btnSubmit" name="btnSubmit" />
It surely is ending nested in the form aspx get by default.
Depending on the layout of your page, you can modify it so you don't end with a nested form. If that's not possible, I think you can't get around to use a form, so instead you'll have to look at a different solution like building the get with js.
The easiest way would be to put that <form> tag outside the main <form runat="server"> tag that usually wraps all ASP.NET controls.
If you're using a master page and the only content placeholder you can use is within that <form runat="server" tag, or you need this form tag in the page structure within the main <form runat="server"> tag then you need to:
Take out the simple <form> tag but leave the HTML <input> tags. Handle the client onclick event (the JavaScript versions, not ASP.NET postback handlers) of the submit button. That handler should grab the e-mail from the text box and issue something like window.location = 'http://www.site.com/emailsignup.aspx?email=....' in Javascript. Make sure to cancel the default HTML button action handler so it doesn't bubble up and submit the ASP.NET form too.