loding dynamic user control giving error

Discussion in 'ASP .Net Web Controls' started by aammi@yahoo.com, Mar 9, 2007.

  1. Guest

    I am tired of this error and now writing a post.

    My Web application has two pages.

    Page one has drop down list which redirect the page to another page . where I am going to load the usercontrol dynamically according to the choice of the user.



    protected void ddlViewReport_SelectedIndexChanged(object sender, EventArgs e)

    {

    if (ddlViewReport.SelectedIndex == 1)

    {

    Session["ReportType"] = ddlViewReport.SelectedIndex;

    Response.Redirect("RepReportingPage.aspx");

    int crosspagevalue = ddlViewReport.SelectedIndex;

    }

    if (ddlViewReport.SelectedIndex == 2)

    {

    Session["ReportType"] = ddlViewReport.SelectedIndex;

    Response.Redirect("RepReportingPage.aspx");







    }
    }



    that code redirect me to the another page "RepRepoortingpage.aspx. There the user contol should load. It is loading but when I add the Textbox or the gridview, it throws and error. "Control 'ctl02_GridView1' of type 'GridView' must be placed inside a form tag with runat=server"

    I tried many things but it still not working. here is the code for the other page where I am loading the control dynamically.



    public partial class RepReportingPage : System.Web.UI.Page

    {

    protected void Page_Load(object sender, EventArgs e)

    {





    int whichControl = Convert.ToInt32(Session["ReportType"]);

    if (whichControl == 1)

    {

    Control UCReportExpense = LoadControl("WebUserControl2.ascx");

    PlaceHolder1.Controls.Add(UCReportExpense);



    }

    else

    {

    Response.Write("would put seocond user control after solving the problem");

    }



    }

    }



    Now any help here please .
    , Mar 9, 2007
    #1
    1. Advertising

  2. marss Guest

    wrote:
    > that code redirect me to the another page "RepRepoortingpage.aspx. There the user contol should load. It is loading but when I add the Textbox or the gridview, it throws and error. "Control 'ctl02_GridView1' of type 'GridView' must be placed inside a form tag with runat=server"
    >


    Put the PlaceHolder1 on the RepReportingPage.aspx "inside a form tag
    with runat=server".

    <form id="form1" runat="server">
    <div>
    <asp:placeHolder ID="PlaceHolder1" runat=server></asp:placeHolder>
    </div>
    </form>
    marss, Mar 12, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    563
  2. sixteenmillion

    The giving that keeps on giving

    sixteenmillion, Nov 19, 2007, in forum: C Programming
    Replies:
    0
    Views:
    425
    sixteenmillion
    Nov 19, 2007
  3. יוני גולדברג

    Giving dynamic value to data control attribute

    יוני גולדברג, Sep 3, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    109
    יוני גולדברג
    Sep 3, 2006
  4. loding dynamic user control giving error

    , Mar 9, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    120
  5. Sushrut Sathe

    mysql loding error

    Sushrut Sathe, May 27, 2009, in forum: Ruby
    Replies:
    1
    Views:
    124
    Roger Pack
    May 27, 2009
Loading...

Share This Page