Tuesday, 3 March 2015

How to add popup modal on button


 Design.aspx

<table width="100%">


        <tr>

            <td align="left" >


                <asp:Button ID="btnsurveydone" runat="server" Text="Survey Done" OnClick="btnsurveydone_Click" CssClass="buttonclassMenu2" BorderStyle="Outset" Width="139px" />
                
                 <asp:ModalPopupExtender ID="btnsurveydone_ModalPopupExtender" runat="server"  Enabled="True" TargetControlID="btnsurveydone" CancelControlID="btnok" PopupControlID="pnlsurveydone" >
                </asp:ModalPopupExtender>
                
                 <asp:Button ID="btnuncomplited" runat="server" Text="Uncomplited Survey" OnClick="btnuncomplited_Click" CssClass="buttonclassMenu2" BorderStyle="Outset" Width="139px"  />
                 <asp:Button ID="btninterval" runat="server" Text="Monthly Report"  OnClick="btninterval_Click" Width="139px" CssClass="buttonclassMenu2" BorderStyle="Outset"  />
                <asp:Button ID="btnEditprofile" runat="server" Text="Edit Profile"  OnClick="btnEditprofile_Click" CssClass="buttonclassMenu2" BorderStyle="Outset" Width="139px"  />
                <asp:Button ID="btnback" runat="server" Text="Back" CssClass="buttonclassMenu" OnClick="btnback_Click" />
            </td>

        </tr>
<tr>
<td>
<asp:Panel ID="pnlsurveydone" runat="server" BackColor="Silver" BorderColor="Green" BorderStyle="Ridge" Height="163px" Width="352px">
</td>
</tr>

Generate Textbox with help of (How many control)

  
Design.aspx

<form id="form1" runat="server">



    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
   <asp:Button ID="Button1" runat="server" Text="Button"  />
   
        <br />
        <asp:Panel ID="pnl" runat="server">

        </asp:Panel>
   
    </div>
    </form>

.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
   

    }
    private void GenerateControls(int count)
    {
        //int count = Convert.ToInt32(TextBox1.Text);
        if (count ==0)
        {
            return;
        }

        for (int i = 0; i < count; i++)
        {
           
            TextBox txt = new TextBox();
            txt.ID = "HARJEET" + i.ToString();
            pnl.Controls.Add(txt);
            pnl.Controls.Add(new LiteralControl("<br/>"));
            Label lbl = new Label();
            lbl.Text = "OPTION" + i.ToString();
           
            pnl.Controls.Add(lbl);
            pnl.Controls.Add(new LiteralControl("<br/>"));

        }
    }
    private void Generate(int count)
    {
       

    }
    private int HowManyControls
    {
        get
        {
            if (ViewState["HowManyControls"] == null)
                return 0;
            else
                return (int)ViewState["HowManyControls"];
        }
        set
        {
            ViewState["HowManyControls"] = value;
        }
    }
    private void GenerateControlscheck(int countcheck)
    {
        //int count = Convert.ToInt32(TextBox1.Text);
        if (countcheck == 0)
        {
            return;
        }

        for (int i = 0; i < countcheck; i++)
        {
            TextBox txt = new TextBox();
            txt.ID = "HARJEET" + i.ToString();
            //Panel2.Controls.Add(txt);
            //Panel2.Controls.Add(new LiteralControl("<br/>"));

        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        HowManyControls = Convert.ToInt32(TextBox1.Text);


        GenerateControls(HowManyControls);
    }
}