I have a page that works fine with multiple a grid and multiple buttons. The page works fine until I add an asp:UpdatePanel. Then I get the following message pushing any of my buttons:
Sys.WebForms.PageRequestManagerServerErrorException: Input string was not in a correct format.
There is no javascript on the page just straight html.
Here is the page:
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPages/Site.Master" AutoEventWireup="true"
CodeBehind="TestUpdatePanel.aspx.cs" Inherits="ASCWeb.TestUpdatePanel" %>
<asp:Content ID="mHeadContent" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="mBodyContent" ContentPlaceHolderID="MainContent" runat="server">
<asp:UpdatePanel ID="pnlUpdate" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtUser" runat="server" />
<asp:ImageButton ID="btnAdd" runat="server" ImageUrl="~/Images/Add.png" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
If I take the TextBox out, it works fine. Nothing is in the code behind.
What would cause this?
Thanks
As per experience, I only encounter that exception when calling Javascript from codebehind, like when using ScriptManager.RegisterClientScriptBlock() to call window.alert(), for instance. But for this issue, I think this resolves it: http://forums.asp.net/t/1823287.aspx/2/10.
Related
I have a master page Header.master which contains a logout button, due to this reason I have to include a form with run at server in my master form.
Again I am using a form in my page because I want to use controls and asp.net compiler says that you cant use controls with form tag with run at server.
Header.master
<form runat="server"><asp:ImageButton ID="btn_logout" runat="server" OnClick="btn_logout_Click" Height="22px" ImageUrl="~/img/logout.png" Width="43px" /></form>
My Page
<%# Page Title="" Language="C#" MasterPageFile="~/Header.Master" AutoEventWireup="true" CodeFile="student_registration.aspx.cs" Inherits="SCMS.student_registration" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<form id="frm_sr" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
</asp:UpdatePanel>
</form>
</asp:Content>
Remove Form tag from your page (My Page)
<form id="frm_sr" runat="server">
Form tag in master page is already enclosing all the code written in page itself
(<asp:Content ID=...>)
I have written an aspx page in c# that uses a master page for a menu. On the child page, I have a scriptmanager control with an update panel. Everything works fine but the master page menu is displayed as a table instead of the menu format. Once the scriptmanager is removed from the child page, the menu is restored.The scriptmanger code is the first item under the content2 section.
<asp:Content ID = "Content2" ContentPlaceHolderID = "MainContent" runat="server">
<h1> Test page 1</h1>
<asp:ScriptManager ID="ScriptManager" runat="server" />
<asp:UpdatePanel ID="UpdatePanel" runat="server" />
<ContentTemplate>
Any help would be appreciated. Thanks!
In your master page at the top try this:
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager> // remove this script manager if you have included script manager in your other page.
// do other stuff.
</form>
</body>
For separate pages include your master file and try this:
<%# Page Title="" Language="C#" MasterPageFile="~/yourmasterfile.Master" AutoEventWireup="true"
CodeBehind="yourfile.aspx.cs" Inherits="yourproject.yourfile" culture="auto" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MasterPageContent" runat="server">
<asp:ScriptManager ID="ScriptManager2" runat="server">
</asp:ScriptManager> // remove this script manager if you have included script manager in master page
<asp:UpdatePanel ID="updatePannel1" runat="server">
<ContentTemplate>
// do your stuff here
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
Ok, so i am doing a project with ASP.net, and using Visual Studio 2012. I created a new master page, in which i wish to make registration. I simply drop the "Create User Wizard" in the Login toolbox onto my page, and it goes completely off its hinges!!
<%# Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="Register.aspx.vb" Inherits="WebApplication1.Register1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" Height="10px" Width="10px">
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
</asp:Content>
I cannot get anything inline like my previous pages.
Any suggestions?
It's not because wizard or something, it's about styles. You have a better browser (Chrome), just open your page in Chrome, right-click on desired element and choose "Inspect element".
Then take a magnifier:
Point this tool to desired element and check out styles on the right:
Try to enable/disable them right there, and you'll see result immediately.
I am using ajax toolkit asyncFileUpload control
I had problem that my server side events does not fired and found this posts Hidden/Shown AsyncFileUpload Control Doesn't Fire Server-Side UploadedComplete Event
I inserted my uploader inside form and with this attributes enctype="multipart/form-data" method="post"
This uploader is inside my webs form which is inside master page
After adding this attributes i got this error
A page can have only one server-side Form tag.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: A page can have only one server-side Form tag.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
And here is my web form
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<form id="Form1" enctype="multipart/form-data" method="post" action="target_url"
runat="server">
<div id="Div1" runat="server">
Just some time to make sure that the page doesn't get reloaded after uploading:
<%=DateTime.Now %><br />
<ajaxToolkit:AsyncFileUpload ID="FileUpload" runat="server" OnUploadedComplete="FileUpload_UploadCompleted"
OnClientUploadComplete="FileUpload_ClientUploadCompleted" OnClientUploadError="uploadError"
OnLoad="FileUpload_OnLoad" />
<asp:Image runat="server" ID="imgUpload" src="" />
<asp:Label runat="server" ID="lblerror" Text="" />
</div>
</form>
</asp:Content>
Your MasterPage already has a form element. Nested forms aren't allowed...
I don't know much about the ajaxToolkit:AsyncFileUpload but, since it is a server control, it should change the parent forms properties. Have you tried removing the form like the code below?
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="Div1" runat="server">
Just some time to make sure that the page doesn't get reloaded after uploading:
<%=DateTime.Now %><br />
<ajaxToolkit:AsyncFileUpload ID="FileUpload" runat="server" OnUploadedComplete="FileUpload_UploadCompleted"
OnClientUploadComplete="FileUpload_ClientUploadCompleted" OnClientUploadError="uploadError"
OnLoad="FileUpload_OnLoad" />
<asp:Image runat="server" ID="imgUpload" src="" />
<asp:Label runat="server" ID="lblerror" Text="" />
</div>
</asp:Content>
Another Possible Solution:
"Pop" a "modal" form that just contains your form with the file upload control. This will remedy the nested forms issue. But, it does changed the functionality.
As a very dirty hack try adding adding a <form></form> in front of your form, and take the runat="server" out of your nested form.
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
**<form></form>**
<form id="Form1" enctype="multipart/form-data" method="post" action="target_url"
>
<div id="Div1" runat="server">
Just some time to make sure that the page doesn't get reloaded after uploading:
<%=DateTime.Now %><br />
<ajaxToolkit:AsyncFileUpload ID="FileUpload" runat="server" OnUploadedComplete="FileUpload_UploadCompleted"
OnClientUploadComplete="FileUpload_ClientUploadCompleted" OnClientUploadError="uploadError"
OnLoad="FileUpload_OnLoad" />
<asp:Image runat="server" ID="imgUpload" src="" />
<asp:Label runat="server" ID="lblerror" Text="" />
</div>
</form>
</asp:Content>
In the past this has worked for me - when forced to work with WebForms. I don't know why but I find that quite a lot with WebForms.
You really should switch to MVC if you want to write code like this however. Even if this does work it's not what I'd call a solution. WebForms just isn't designed to do this.
I have had this problem for a while now and no matter what i cannot seem to resolve it. I have a master page and a content page.
The content page simply contains a button
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</asp:Content>
The master page simply contains the content place holders. The button1 one event fires normally, however as soon as a form is added to the master page the button stops firing. the master page looks something like this
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
Member Login
<asp:Button ID="btnLogin" runat="server" Text="Login" CssClass="bt_login"
onclick="btnLogin_Click" />
</form>
</div>
</div>
</div>
</div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</form>
Can some one please help, the button works fine without the form in teh master page, however i need a form in the master page
Thanks
Ok after running the exact same project on another machine, everything worked fine. So I'm guessing there is an issue with the way i installed visual studio and asp.net.