About the type "LinkButton" of the control "XXX" must be placed in a solution with runat=server in the form tag.

Source: Internet
Author: User

1. First confirm that the LinkButton control is included in the form, check that the form has no runat tag, and if so, keep looking.

2. If you see here, it is estimated that you are doing Excel export function. Override the Verifyrenderinginserverform method in the background code:

public override void Verifyrenderinginserverform (Control control)

{

Confirms that a HtmlForm control is rendered for

}

Personally, this problem occurs because the type of browser response is context when you export Excel . Response.contenttype=" application/excel " ; instead of the regular "text/html" type, when the browser responds to the server to download Excel, it has "forgotten" the current page (it is not appropriate to say so, just remember to respond to the current user's Excel export request, Therefore, there is an exception that LinkButton not loaded in the form.

MSDN's explanation for this method:

&lt;form runat=server&gt;Tags can call this method before they render so, an error message was shown if they is placed outside the tags. ' data- Guid= "f7a5af4f0d75f561cd983dbfac3e6489" > must be located in<form runat=server>The control in the tag can call this method before rendering to display an error message when the control is placed outside the tag. Control. Rendermethod. ' data-guid= ' cdf456570cc8ff09c576e40f2da0db0e ' > The control that sends back or relies on a registered script block should beControl. RenderThis method is called in the override of the method.A page that renders a server form element differently can override this method to throw an exception under different conditions.

HtmlForm server Control ( &lt; form runat= "Server" &GT; ) tags. ' data-guid= ' 39df9c092648eb5d1bd8b0c6dc13de66 > If server controls that postback or use client script are not included in   HtmlForm   server controls (< form runat= "Server"; ) tags, and they will not work correctly.   HtmlForm Control. ' Data-guid= ' e4c1e9d790ef36589fb13c738b3b2494 > These controls can invoke the method at render time, as they are not contained in   HtmlForm An explicit error message is provided in the   control.

render method for any kind of input tag. ' Data-guid= ' 8885eb6 3d3adf2da4550247b0a490beb "> When developing a custom server control, &NBSP is typically overridden for any type of input tag; render The method is called when the   method is used.   getpostbackeventreference , or if it emits client script. ' Data-guid= "7d5a29c39bd6ca6ed7e5c02bd60f5004" > This is called   in the input control; getpostbackeventreference   Or when issuing client script.   The composite server control does not need to make this call.

3. Small partners may find that after rewriting the Verifyrenderinginserverform page still error, but no longer reported ' type ' LinkButton ' control "XXX" must be placed in the form tag with Runat=server ' This is wrong, and that's a good news. The specific error message is: You can only call registerForEventValidation during Render () execution (registerForEventValidation can only is called during Render ();)

Workaround: Add enableeventvalidation = "false" in the page directive of the foreground ASPX page and modify the following:

<%@ page language= "C #" enableEventValidation = "false" autoeventwireup= "true" codefile= "ExportRepeater.aspx.cs" inherits= "exportrepeater"%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.