Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I have made a grid view to add an additional detail which contains an checkbox for manadatory field and a textbox for additional name .When I checked this checkbox, I want to show additional detail on other page which made the field manadatory dynamically.
Posted
Comments
prabhugi2it 21-Dec-13 0:20am    
please give some additional details about your "other page"..
ssss0001 21-Dec-13 0:30am    
Suppose on additional field page , I have add a passport and make that field manadatory by checking on checkbox.Now on other page, I have to show passport field with * sign and make it manadatory dynamically
prabhugi2it 21-Dec-13 0:33am    
okay ..few mints

1 solution

Please try the below code

XML
<div>
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:PlaceHolder ID="plh" runat="server"></asp:PlaceHolder>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:Button ID="btnupload" runat="server" Text="Upload" OnClick="btnupload_Click" />
    <asp:Label ID="lblerror" runat="server" ></asp:Label>
</div>




void Page_Init()
    {
        
        Label lb = new Label();
        lb.ID = "1";
        lb.Font.Name = "Arial";
        lb.Font.Size = 10;
        lb.Font.Bold = true;
        lb.ForeColor = System.Drawing.Color.SteelBlue;
        

        FileUpload FileUploadVal = new FileUpload();
        FileUploadVal.ID = "FileUploadVal." + 1;

        lb.Text = "Question";

        Label lb0 = new Label();
        lb0.ID = "lb0." + 1;
        lb0.Font.Name = "Arial";
        lb0.Font.Size = 10;
        lb0.Font.Bold = true;
        lb0.ForeColor = System.Drawing.Color.Red;

        lb0.Text = "*" + "<br/>";
        lb0.Visible = false;
        lb.Visible = false;

        lb.Visible = true;
        lb0.Visible = true;

        plh.Controls.Add(lb);
        plh.Controls.Add(lb0);
        plh.Controls.Add(FileUploadVal);


    }
    protected void btnupload_Click(object sender, EventArgs e)
    {
        foreach (Control ctrl in plh.Controls)
        {
            if (ctrl.GetType().ToString() == "System.Web.UI.WebControls.FileUpload")
            {
                if (((FileUpload)ctrl).HasFile)
                {
                    //your code
                }
                else
                {
                    lblerror.Text = "please upload a file before click";
                    lblerror.ForeColor = System.Drawing.Color.Red;

                }
            }
        }
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900