asp.net c# bootstrap ile msgbox confirm dialog yapmak (codebehind dan aç kapat) sample



--- in html markup

<div runat="server" class="modal fade bs-modal-md" id="msgBox" tabindex="-1" role="dialog" style="background: rgba(0, 0, 0, 0.31);" aria-hidden="true">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-header">
   <div class="col-md-12">

<asp:LinkButton ID="btnBirak" runat="server" CssClass="pull-right" OnClick="btnVazgec_Click" Visible="true">
<span aria-hidden="true" class="glyphicon glyphicon-remove-sign"   data-toggle="tooltip" title="Vazgeç...." ></span></asp:LinkButton>

                              <asp:Label ID="msglblBaslik" runat="server" Text="..." Font-Bold="false" Font-Size="Medium" class="modal-title"></asp:Label>
                         </div>
                    </div>
<%--------------------------------------------%>
                    <div class="modal-body">
                        <div class="row" style="margin-bottom: 15px;">
                            <div class="col-md-12">
                                <asp:Label ID="msglblMesaj" runat="server" Text="..." Font-Bold="true" Font-Size="Medium" class="modal-title"></asp:Label>
                            </div>
                        </div>
<%--------------------------------------------%>
                        <div class="modal-footer">

  <asp:Button ID="msgbtnEvet" runat="server" Text="Evet" OnClick="btnEvet_Click" class="btn btn-success pull-left" data-dismiss="modal" />
<asp:Button ID="msgbtnHayir" runat="server" Text="Hayır" OnClick="btnHayir_Click" class="btn btn-danger pull-right" data-dismiss="modal" />

                        </div>
                </div>
</div>
</div>
</div>




-- in code behind

protected void ASPxButtonTest_Click(object sender, EventArgs e)
{
if (this.TextBox1.Text.Trim()=="")
{
mesajVer("Boş olamaz...!");
this.TextBox1.Focus();
return;
}
else
{
mesajVer(this.TextBox1.Text.Trim(),System.DateTime.Now.ToString());
}
}


private void mesajVer(string mesaj,string Baslik="Bilgi..")
{
msgBox.Attributes["class"] += " in";
msgBox.Attributes["style"] += " display: block; padding-right: 17px;";
msglblMesaj.Text = mesaj;
msglblBaslik.Text = Baslik;
}



protected void btnEvet_Click(object sender, EventArgs e)
{
msgBox.Attributes["class"] = "modal fade bs-modal-lg";
msgBox.Attributes["style"] = "display: none;";

Response.Write("Evete basıldı");
}
protected void btnHayir_Click(object sender, EventArgs e)
{
msgBox.Attributes["class"] = "modal fade bs-modal-lg";
msgBox.Attributes["style"] = "display: none;";

Response.Write("Hayıra basıldı");
}
protected void btnVazgec_Click(object sender, EventArgs e)
{
msgBox.Attributes["class"] = "modal fade bs-modal-lg";
msgBox.Attributes["style"] = "display: none;";

Response.Write("Vazgeçe basıldı");
}



Yorumlar