Friday, 13 July 2012

Textbox validation to accept only integer / Only integer with fixed length /only character or show in a validation summery

 //Only Take Integer Value through out the page in that control which textbox not take an integer value

 <script type="text/javascript">
        function numeric_only(e) {
            var unicode = e.charCode ? e.charCode : e.keyCode;
            if (unicode == 8 || unicode == 9 || (unicode >= 48 && unicode <= 57)) {
                return true;
            }
            else {
                return false;
            }
        }
    </script>
<asp:TextBox ID="TxtNextPurchaseOrderNumber" runat="server" onkeypress="return numeric_only(event);"/> 


//Only Take Integer Value
<script type="text/javascript">
    function validate(s) {
        var x = s.keyCode;
        var Zip = document.getElementById('<%=TxtRoundupPlace.ClientID %>');
        var j = "0123456789"
        for (var i = 0; i < Zip.value.length; i++) {
            if (j.search(Zip.value.charAt(i)) == -1) {
                alert('Round Place should be Numeric ');
                Zip.value = "";
                return false;
            }
        }
    }
</script>
//Event write in this format
   <asp:TextBox ID="TxtRoundupPlace" Text="" runat="server" onkeyUp="return validate(event)" />
______________________________________________________________________________
if i want  one TextBox take only integer value and  6 digits number thats way
    <script type="text/javascript">

        function validate(s)
         {
             var x = s.keyCode;
             var Zip = document.getElementById('<%=
TxtRoundupPlace.ClientID %>');
             var j = "0123456789"
             for (var i = 0; i < Zip.value.length; i++) {

                 if (j.search(Zip.value.charAt(i)) == -1) {
                     alert('Zip code  should be Numeric ');
                     Zip.value = "";
                     return false;
                 }
             }

             if (Zip.value.length >= 7)
            {
                alert('Zip code lenght must be less than Seven');
                Zip.value = "";
                return false;
            }
    </script>
   <asp:TextBox ID="TxtRoundupPlace" Text="" runat="server" onkeyUp="return validate(event)" />
 ___________________________________________________________________________
//Only Take Character or String Value
<script type="text/javascript">
    function AllowAlphabet(e) {
        isIE = document.all ? 1 : 0
        keyEntry = !isIE ? e.which : event.keyCode;
        if (((keyEntry >= '65') && (keyEntry <= '90')) || ((keyEntry >= '97') && (keyEntry <= '122')) || (keyEntry == '46') || (keyEntry == '32') || keyEntry == '45')
            return true;
        else {
            alert("Please Enter Only Character values.");
            return false;
        }
    }
</script>
//Event write in this format 
      <asp:TextBox ID="TxtCurrencySubString" Text="" runat="server" onkeypress="return AllowAlphabet(event)" /> 
____________________________________________________________________________
TextBox Take only two digit decimal places after number using Java script  
<script type ="text/javascript">
    function MaskMoney(evt)
    {
    if (!(evt.keyCode == 46 || (evt.keyCode >= 48 && evt.keyCode <= 57)))
return false;
    var parts = evt.srcElement.value.split('.');
    if (parts.length > 2) return false;
    if (evt.keyCode == 46) return (parts.length == 1);
    if (parts[0].length >= 14) return false;
    if (parts.length == 2 && parts[1].length >= 2) return false;
    }
</script>

filename.aspx.cs("onKeyPress)

protected void Page_Load(object sender, EventArgs e)
        {
           TextBox1.Attributes.Add("onKeypress", "return MaskMoney(event)");
        }
[Or]
filename.aspx.cs("onKeyDown)
protected void Page_Load(object sender, EventArgs e)
        {
           TextBox1.Attributes.Add("onKeydown", "return MaskMoney(event)");
        }
_______________________________________________________________________________
 //This Red Color is allow to a textbox only String Value (1,10) means 10 Character
<asp:TextBox ID="TxtCurrencySymbol" Text="" runat="server"  />
              <asp:RegularExpressionValidator ID="RegCurrencySymbol" runat="server"
                ControlToValidate="TxtCurrencySymbol" ValidationExpression="^[a-zA-Z'.\s]{1,10}$"
                ErrorMessage="Currency Symbol Only Characters !"  Display="None">*</asp:RegularExpressionValidator>
 //This Red Color is allow to a textbox only IntegerValue
   <asp:RegularExpressionValidator ID="regRoundPlace" runat="server" ControlToValidate="TxtRoundupPlace"
                ValidationExpression="[0-9]+"  ErrorMessage="Roundup Place Should be numeric value !" Display="None">*</asp:RegularExpressionValidator> 

//This message is show in a Validation Summery
 asp:ValidationSummary ID="ValidationAllMessage" runat="server" ShowMessageBox="true" ShowSummary="false"  />

Thursday, 12 July 2012

How to find Parent page Dropdownlist in childpage and auto refresh

 protected void BtnSave_Click(object sender, EventArgs e)
        {
            if (BtnSave.Text == "Save")
            {
                Save();
                Message("Data Inserted Successfully .!");
                DropDownList DdlGroup = (DropDownList)this.Parent.FindControl("ddlGroup");
                if (DdlGroup != null)
                {
                    List<UFMS_Group> listGroup = new List<UFMS_Group>();
                    listGroup = UERPManagement.GetInstance.GetAllGroups();
                    var lnqGroup = from grp in listGroup

                                   select grp;
                    DdlGroup.DataSource = lnqGroup.ToList();
                    DdlGroup.DataTextField = "Group_Name";
                    DdlGroup.DataValueField = "Group_ID";
                    DdlGroup.DataBind();
                    DdlGroup.Items.Insert(0, UserCommand.Select.ToString());
                }
            }

            else
            {
                update();
                //FillGridViewGroup();
                Message("Data Updated Successfully .!");
            }
        }

Wednesday, 11 July 2012

Transaction in ASPX page Example

  public void Test()
        {
            SqlTransaction trans;
            string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            SqlConnection connection = new SqlConnection(connStr);
            try
            {
                connection.Open();
                trans = connection.BeginTransaction();
                String queryString = "INSERT SOME STUFF";
                SqlCommand command = new SqlCommand(queryString, connection);
                command.Transaction = trans;
                command.ExecuteNonQuery();
                queryString = "INSERT SOME OTHER STUFF";
                command = new SqlCommand(queryString, connection);
                command.Transaction = trans;
                command.ExecuteNonQuery();
                trans.Commit();
            }
            catch (Exception ex)
            {
                //trans.Rollback();
                //errMsg.Text = ex.Message;
            }
            finally
            {
                if (connection != null)
                    connection.Close();
            }
        }

Friday, 6 July 2012

At a time multiple data inserted in a single field using Data Table

    private DataTable GetTableData()
        {
            string NumberingType = "";
            bool fyear;


            DataTable dt = new DataTable();
            if (RadNumbering.Checked == true)
            {
                NumberingType = "Manual";
                dt.Columns.Add("Company_ID", typeof(int));
                dt.Columns.Add("Voucher_Numbering_Type", typeof(string));
                dt.Columns.Add("Voucher_Type", typeof(string));
                dt.Columns.Add("Prefix", typeof(string));
                dt.Columns.Add("With_Financial_Year", typeof(bool));
                dt.Columns.Add("Auto_Number_Size", typeof(int));

                //dt.Columns.Add("CreatedOn", typeof(string));
                //dt.Columns.Add("CreatedBy", typeof(int));
                //dt.Columns.Add("ModifiedOn", typeof(string));
                //dt.Columns.Add("ModifiedBy", typeof(int));
                //============
                if (TxtCashReceiptPrefix.Text != "")
                {
                    if (TxtCashPaymentPrefix.Text != "")
                    {
                        if (ChkCashPaymentFYear.Checked == true)
                        {
                            fyear = Convert.ToBoolean(1);
                        }
                        else
                        {
                            fyear = Convert.ToBoolean(0);
                        }

                        dt.Rows.Add(1, "Manual", LblCasPayment.Text, TxtCashPaymentPrefix.Text, fyear, TxtCashPaymentAutoNoSize.Text);
                    }
                    if (ChkCashReceiptFYear.Checked == true)
                    {
                        fyear = Convert.ToBoolean(1);
                    }
                    else
                    {
                        fyear = Convert.ToBoolean(0);
                    }

                    dt.Rows.Add(1, "Manual", LblCashReceipt.Text, TxtCashReceiptPrefix.Text, fyear, TxtCashReceiptAutoNoSize.Text);
                }

                if (TxtBankPaymentPrefix.Text != "")
                {
                    if (ChkBankPaymentFYear.Checked == true)
                    {
                        fyear = Convert.ToBoolean(1);
                    }
                    else
                    {
                        fyear = Convert.ToBoolean(0);
                    }
                    dt.Rows.Add(1, "Manual", LblBankPayment.Text, TxtBankPaymentPrefix.Text, fyear, TxtBankPaymentAutoNoSize.Text);
                }
                if (TxtBankReceiptPrefix.Text != "")
                {
                    if (ChkBankReceiptFYear.Checked == true)
                    {
                        fyear = Convert.ToBoolean(1);
                    }
                    else
                    {
                        fyear = Convert.ToBoolean(0);
                    }
                    dt.Rows.Add(1, "Manual", LblBankReceipt.Text, TxtBankReceiptPrefix.Text, fyear, TxtBankReceiptAutoNoSize.Text);
                }
                if (TxtJVoucherPrefix.Text != "")
                {
                    if (ChkJVVoucherFYear.Checked == true)
                    {
                        fyear = Convert.ToBoolean(1);
                    }
                    else
                    {
                        fyear = Convert.ToBoolean(0);
                    }
                    dt.Rows.Add(1, "Manual", LblJournalVoucher.Text, TxtJVoucherPrefix.Text, fyear, TxtJVVoucherAutoNoSize.Text);
                }
                if (TxtContraoucherPrefix.Text != "")
                {
                    if (ChkContraVoucherFYear.Checked == true)
                    {
                        fyear = Convert.ToBoolean(1);
                    }
                    else
                    {
                        fyear = Convert.ToBoolean(0);
                    }
                    dt.Rows.Add(1, "Manual", LblContraVoucher.Text, TxtContraoucherPrefix.Text, fyear, TxtContraVoucherAutoNoSize.Text);
                }
                if (TxtPurOrderPrefix.Text != "")
                {
                    if (ChkPurOrderFYear.Checked == true)
                    {
                        fyear = Convert.ToBoolean(1);
                    }
                    else
                    {
                        fyear = Convert.ToBoolean(0);
                    }
                    dt.Rows.Add(1, "Manual", LblPurOrder.Text, TxtPurOrderPrefix.Text, fyear, TxtPurOrderAutoNoSize.Text);
                }

                if (TxtSalesOrderPrefix.Text != "")
                {
                    if (ChkSalesOrderFYear.Checked == true)
                    {
                        fyear = Convert.ToBoolean(1);
                    }
                    else
                    {
                        fyear = Convert.ToBoolean(0);
                    }
                    dt.Rows.Add(1, "Manual", LblSalesOrder.Text, TxtSalesOrderPrefix.Text, fyear, TxtSalesOrderAutoNoSize.Text);
                }
                if (TxtPurchReturnPrefix.Text != "")
                {
                    if (ChkPurchReturnFYear.Checked == true)
                    {
                        fyear = Convert.ToBoolean(1);
                    }
                    else
                    {
                        fyear = Convert.ToBoolean(0);
                    }
                    dt.Rows.Add(1, "Manual", LblPurchReturn.Text, TxtPurchReturnPrefix.Text, fyear, TxtPurchReturnAutoNoSize.Text);
                }
                if (TxtSalesReturnPrefix.Text != "")
                {
                    if (ChkSalesReturnFYear.Checked == true)
                    {
                        fyear = Convert.ToBoolean(1);
                    }
                    else
                    {
                        fyear = Convert.ToBoolean(0);
                    }
                    dt.Rows.Add(1, "Manual", LblSalesReturn.Text, TxtSalesReturnPrefix.Text, fyear, TxtSalesReturnAutoNoSize.Text);
                }
                if (TxtStockTranVoucherPrefix.Text != "")
                {
                    if (ChkStockTranVoucherFYear.Checked == true)
                    {
                        fyear = Convert.ToBoolean(1);
                    }
                    else
                    {
                        fyear = Convert.ToBoolean(0);
                    }
                    dt.Rows.Add(1, "Manual", LblStockTranVoucher.Text, TxtStockTranVoucherPrefix.Text, fyear, TxtStockTranVoucherAutoNoSize.Text);
                }
                if (TxtStockInvVoucherPrefix.Text != "")
                {
                    if (ChkStockInvVoucherFYear.Checked == true)
                    {
                        fyear = Convert.ToBoolean(1);
                    }
                    else
                    {
                        fyear = Convert.ToBoolean(0);
                    }
                    dt.Rows.Add(1, "Manual", LblStockInvVoucher.Text, TxtStockInvVoucherPrefix.Text, fyear, TxtStockInvVoucherAutoNoSize.Text);
                }
                if (TxtMatReceiveVoucherPrefix.Text != "")
                {
                    if (ChkMatReceiveVoucherFYear.Checked == true)
                    {
                        fyear = Convert.ToBoolean(1);
                    }
                    else
                    {
                        fyear = Convert.ToBoolean(0);
                    }
                    dt.Rows.Add(1, "Manual", LblMatReceiveVoucher.Text, TxtMatReceiveVoucherPrefix.Text, fyear, TxtMatReceiveVoucherAutoNoSize.Text);
                }
                UFMS_VoucherSetups vouchers = new UFMS_VoucherSetups();
                if (ChkWarningVouList.Checked == true)
                {
                    vouchers.Warning_Before_Last_Voucher_List = Convert.ToBoolean(1);
                }
                vouchers.Complete_Voucher_List_Warning_Message = TxtWarningMessage.Text;
                if (RadYearly.Checked)
                {
                    vouchers.Renumbering_Frequency = RadYearly.Text;
                }
                else if (RadMonthly.Checked)
                {
                    vouchers.Renumbering_Frequency = RadMonthly.Text;
                }
                else
                {
                    vouchers.Renumbering_Frequency = RadQuartly.Text;
                }
                if (RadYes.Checked)
                {
                    vouchers.Fix_Length_Numeric_Part = Convert.ToBoolean(1);
                }
                else
                {
                    vouchers.Fix_Length_Numeric_Part = Convert.ToBoolean(0);
                }
                vouchers.Company_ID = 1;
                vouchers.Voucher_Numbering_Type = NumberingType.ToString();
                UERPManagement.GetInstance.InsertVoucherSetupManual(dt, vouchers);
                Label5.Text = "Data Inserted Successfulley";
            }
            if (RadAutomatic.Checked == true)
            {
                UFMS_VoucherSetups newvouchers = new UFMS_VoucherSetups();
                newvouchers.Company_ID = 1;
                newvouchers.Duplicate_Voucher = DrpDuplicateVoucher.SelectedItem.Text;
                newvouchers.Blank_Voucher = DdlBlankVoucher.SelectedItem.Text;
                UERPManagement.GetInstance.InsertVoucherSetup(newvouchers);
                Label5.Text = "Data Inserted Successfulley";
            }
            return dt;
        }


-------------------------------------------------------------------
public void InsertVoucherSetupManual(DataTable dt, UFMS_VoucherSetups vouchers)
        {
           
          
            //==================================================
            // Add Voucher_Numbering_Type
            SqlCommand updateCommand = new SqlCommand("Ufms.KC_UpdateParty");
            updateCommand.CommandType = CommandType.StoredProcedure;
            updateCommand.Parameters.Add(GetParameter("@Company_ID", SqlDbType.Int, vouchers.Company_ID));
            updateCommand.Parameters.Add(GetParameter("@Warning_Before_Last_Voucher_List", SqlDbType.Bit, vouchers.Warning_Before_Last_Voucher_List));
            updateCommand.Parameters.Add(GetParameter("@Voucher_Numbering_Type", SqlDbType.VarChar, vouchers.Voucher_Numbering_Type));
            updateCommand.Parameters.Add(GetParameter("@Complete_Voucher_List_Warning_Message", SqlDbType.VarChar, vouchers.Complete_Voucher_List_Warning_Message));
            updateCommand.Parameters.Add(GetParameter("@Renumbering_Frequency", SqlDbType.VarChar, vouchers.Renumbering_Frequency));
            updateCommand.Parameters.Add(GetParameter("@Fix_Length_Numeric_Part", SqlDbType.Bit, vouchers.Fix_Length_Numeric_Part));
            ExecuteStoredProcedure(updateCommand);
            //==================================================
            //VoucherSetup
            foreach (DataRow dr in dt.Rows)
            {
                SqlCommand insertCommand = new SqlCommand("Ufms.KC_InsertVoucherSetup");
                insertCommand.CommandType = CommandType.StoredProcedure;
   
                insertCommand.Parameters.Add(GetParameter("@Company_ID", SqlDbType.VarChar, dr["Company_ID"].ToString()));
                insertCommand.Parameters.Add(GetParameter("@Voucher_Numbering_Type", SqlDbType.VarChar, dr["Voucher_Numbering_Type"].ToString()));  
                insertCommand.Parameters.Add(GetParameter("@Voucher_Type", SqlDbType.VarChar, dr["Voucher_Type"].ToString()));
                insertCommand.Parameters.Add(GetParameter("@Prefix", SqlDbType.VarChar, dr["Prefix"].ToString()));
                insertCommand.Parameters.Add(GetParameter("@With_Financial_Year", SqlDbType.Bit, dr["With_Financial_Year"].ToString()));
                insertCommand.Parameters.Add(GetParameter("@Auto_Number_Size", SqlDbType.Int, dr["Auto_Number_Size"].ToString()));

                //insertCommand.Parameters.Add(GetParameter("@Created_On", SqlDbType.DateTime, dr["Created_On"].ToString()));
                //insertCommand.Parameters.Add(GetParameter("@Created_By", SqlDbType.Int, dr["Created_By"].ToString()));
                //insertCommand.Parameters.Add(GetParameter("@Modified_On", SqlDbType.DateTime, dr["Modified_On"].ToString()));
                //insertCommand.Parameters.Add(GetParameter("@Modified_By", SqlDbType.Int, dr["Modified_By"].ToString()));

                ExecuteStoredProcedure(insertCommand);
            }
        }

Auto Generated Id in Sql

ALTER PROCEDURE [fms].[KC_InsertBankPaymentReceipt]
(
@NEWID int=null,
@VoucherDate datetime=null,
--@VoucherNo varchar(30)=null,
@CompanyID int=null,
@VoucherType varchar(20)=null,
@VoucherAmount decimal(18,2)=null,
@InvoiceRefNo nchar(10)=null,
@BankName varchar(50)=NULL,
@TransactionType varchar(50)=null,
@InstrumentNo varchar(50)=NULL,
@InstrumentDate datetime=NULL,
@Narration varchar(500)=null,
@RegOrOpt varchar(20)=NULL,
@PostDated bit=NULL,
@DayBookID int=null,
--@FYear nvarchar(20)=null,

@SlNo int=null,
@LedgerID int=null,
@LedgerID2 int=null,
@DrAmount decimal=null,
@CrAmount decimal=null,
@CreatedOn DATETIME=null,
@CreatedBy INT=null,
@ModifiedOn DATETIME=null,
@ModifiedBy INT=null,
@Out varchar(20)=null Output
)
AS
BEGIN
   
        BEGIN TRANSACTION
            --===========Generate an user defined Voucher No ===============
            DECLARE @VoucherNo varchar(30)
                    SELECT    @VoucherNo = VoucherNo
            FROM fms.FMS_Vouchers
            WHERE VoucherType=@VoucherType

            DECLARE @Year int
            SELECT @Year=year(getdate())
            DECLARE @FYear varchar(10)
            IF month(getdate())<3
                BEGIN
                    select @FYear=CONVERT(varchar, @Year-1) +'-'+ CONVERT(varchar, @Year)
                END
            ELSE
                BEGIN
                    select @FYear=CONVERT(varchar, @Year) +'-'+ CONVERT(varchar, @Year+1)
                END

            IF @VoucherNo IS NULL
                BEGIN
                        IF @VoucherType='BankPayment'
                        BEGIN
                            SELECT @VoucherNo='BP/000001/'+@FYear
                        END
                        IF @VoucherType='BankReceipt'
                        BEGIN
                            SELECT @VoucherNo='BR/000001/'+@FYear
                        END
                        IF @VoucherType='CashPayment'
                        BEGIN
                            SELECT @VoucherNo='CP/000001/'+@FYear
                        END
                        IF @VoucherType='CashReceipt'
                        BEGIN
                            SELECT @VoucherNo='CR/000001/'+@FYear
                        END
                        IF @VoucherType='JournalVoucher'
                        BEGIN
                            SELECT @VoucherNo='JV/000001/'+@FYear
                        END
                        IF @VoucherType='ContraVoucher'
                        BEGIN
                            SELECT @VoucherNo='CV/000001/'+@FYear
                        END
                        set @Out=@VoucherNo
                END
            ELSE
                BEGIN
                   
                    DECLARE @P1 VARCHAR(20)
                    DECLARE @P2 VARCHAR(20)
                    DECLARE @P3 VARCHAR(20)
                    set @P1=Substring(@VoucherNo,1,2)
                    set @P2=Substring(@VoucherNo,4,6)
                    set @P3=Substring(@VoucherNo,11,9)
                    set @P2=cast(@P2 as int)+1
                    set @P2=RIGHT('000000' + RTRIM(@P2), 6)
                    set @VoucherNo=@P1+'/'+@P2+'/'+@P3
                    --Select @P1, @P2, @P3, @VoucherNo
                    set @Out=@VoucherNo
                END

            --===========End of Generate an user defined Voucher No ========
            INSERT INTO fms.FMS_Vouchers
            (
            VoucherDate,VoucherNo,CompanyID,VoucherType,VoucherAmount,InvoiceRefNo,BankName,TransactionType,
            InstrumentNo,InstrumentDate,Narration,RegOrOpt,PostDated,DayBookID,
            --FYear,
            CreatedOn,CreatedBy,
            ModifiedOn,ModifiedBy
            )
            VALUES
            (
            @VoucherDate,@VoucherNo,@CompanyID,@VoucherType,@VoucherAmount,@InvoiceRefNo,@BankName,
            @TransactionType,@InstrumentNo,@InstrumentDate,@Narration,@RegOrOpt,@PostDated,@DayBookID,
            --@FYear,
            GETDATE(),@CreatedBy,GETDATE(),
            @ModifiedBy
            )
            SET @NEWID=SCOPE_IDENTITY()
           
            INSERT INTO fms.FMS_VoucherDetails
            (VoucherID,SlNo,LedgerID,DrAmount,CrAmount,CreatedOn,CreatedBy,ModifiedOn,ModifiedBy) VALUES
            (@NEWID,@SlNo,@LedgerID,@DrAmount,@CrAmount,GETDATE(),@CreatedBy,GETDATE(),@ModifiedBy)
           
            INSERT INTO fms.FMS_VoucherDetails
            (VoucherID,SlNo,LedgerID,DrAmount,CrAmount,CreatedOn,CreatedBy,ModifiedOn,ModifiedBy)
            VALUES(@NEWID,@SlNo,@LedgerID2,@CrAmount,@DrAmount,GETDATE(),@CreatedBy,GETDATE(),@ModifiedBy)
           
            IF @@ERROR!=0
                ROLLBACK TRAN
            else
                COMMIT TRAN
                select @Out
               
END

How to Create a user control and how to use in aspx page.

First Right click on your website -> Add one Ascx Page.
 Next .
//This is a popup window mean show message in a user control
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="U_Message.ascx.cs" Inherits="Website.App_WebControls.UFMS_UserControls.U_Message" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
 <asp:Button runat="server" ID="BtnMessage" Style="display: none" />
    <asp:ModalPopupExtender ID="modalMessage" runat="server" TargetControlID="BtnMessage"
        PopupControlID="PnlMessage" OkControlID="Okbtn" CancelControlID="imgClose" BackgroundCssClass="ModalBackgroundCSS">
    </asp:ModalPopupExtender>
    <asp:Panel runat="Server" ID="PnlMessage" DefaultButton="Okbtn" Style="border: solid 2px #BBBBBB;
        font-family: Arial; width: 325px; height: 150px">
        <table style="width: 100%; border: 0px none;border-collapse:collapse; " cellspacing="-1" cellpadding="-1" >
            <tr style="background-color:Teal; height: 30px; color: White; font-size: 15px;">
                <td colspan="2">
                    <table style="width: 100%;">
                        <tr>
                            <td style="width: 95%">
                                Message from KenCloud
                            </td>
                            <td>
                                <asp:Image ID="imgClose" runat="server" ImageUrl="../../images/quite.png" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr style="background-color: White; height: 90px">
                <td align="right">
                    <asp:Image ID="imgError" runat="server" ImageUrl="~/images/error.jpg" />
                </td>
                <td>
                    <div style="margin-left: 2%; width: 90%; font-size: 13px;">
                        <asp:Label ID="LblModalMessage" runat="server" Text=""></asp:Label></div>
                </td>
            </tr>
            <tr style="height: 30px; background-color: Teal">
                <td colspan="2" align="right">
                    <asp:Button ID="Okbtn" runat="server" Text="OK" Width="90px" Font-Size="13px" CausesValidation="false" />
                </td>
            </tr>
        </table>
    </asp:Panel>
----------------------------------------------------------------------------------------------------
Next Add one Aspx page then add this type.

<%@ Register Src="~/App_WebControls/UFMS_UserControls/U_Message.ascx" TagName="Message" TagPrefix="Mess" %> 

 // Some times it will take Problem so to add in write
 <Mess:Message ID="MessageID" runat="server" Visible="false" /> 

// if you want to retrive Parent user control id in child control and also add Usercontrol Path
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<%@ Register Src="~/App_WebControls/UFMS_UserControls/U_Message.ascx" TagName="Mess" TagPrefix="me" %>
<%@ Register Src="~/App_WebControls/UFMS_UserControls/U_VoucherSetup.ascx" TagName="Voucherset" TagPrefix="voucher" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<voucher:Voucherset ID="VouchersSetups" runat="server" />
<me:Mess ID="Meid" runat="server" />
</asp:Content>

  protected void BtnCashPaymentDisp_Click(object sender, EventArgs e)
        {

            a = TxtCashPaymentPrefix.Text;
            if (ChkCashPaymentFYear.Checked)
            {
                b = "2011-2012";
            }
            c = Convert.ToInt32(TxtCashPaymentAutoNoSize.Text);
            for (int i = 1; i < c; i++)
            {
                x += "0";
                Response.Write(x.ToString());
            }
            x = (x + "1");
            string Cashpayment = (a + "/" + b + "/" + x).ToString();
            Message(Cashpayment.ToString());
        }

//To show Popop Window
void Message(string msg)
        {           
            U_Message uc = (U_Message)Parent.FindControl("Meid");

            if (uc != null)
            {
                Label lb = (Label)uc.FindControl("LblModalMessage");
                lb.Text = msg;
                MessageID.Visible = true;
                AjaxControlToolkit.ModalPopupExtender modal = (AjaxControlToolkit.ModalPopupExtender)uc.FindControl("modalMessage");
                modal.Show();
            }
        }