Asp .net Ajax modalpopup event

Hi, i have a asp .net page. there is a button in the page and it validates user account information and logins to system. and i design a modalpopup and it works like a messagebox. i want to show the modalpopup if the user informations is not valid. how can i do. now modalpopup opens every click event. thanks for help.
adminenderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

P1ST0LPETECommented:
Here is a good walk through on how to create/use the modal popup in asp.net.  The example is showing images in the popup, but the general functionality is there for what you need.

http://www.vbdotnetheaven.com/UploadFile/rahul4_saxena/ModalPopupWindowInASPdotNet01282009001458AM/ModalPopupWindowInASPdotNet.aspx
adminenderAuthor Commented:
My problem is this:
this is my login page. and this is the code for login button

   Protected Sub btn_giris_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_giris.Click

        If (txt_kullanici_adi.Text.Length = 0) Then

            ModalPopupExtender1.TargetControlID = "btn_giris"
            Label1.Text = "Lütfen Kullanici Adi Giriniz!"
            ModalPopupExtender1.Show()

        ElseIf (txt_sifre.Text.Length = 0) Then
            ModalPopupExtender1.TargetControlID = "btn_giris"
            Label1.Text = "Lütfen Sifre Giriniz!"
            ModalPopupExtender1.Show()

        Else
            If (con.State = Data.ConnectionState.Closed) Then
                con.Open()
            End If
            sorgu.CommandText = "select fn1, fn2, fn3, fn4 from gm_tbl1 where(fn2='" + txt_kullanici_adi.Text + "')"
            If (con.State = Data.ConnectionState.Open) Then
                con.Close()
            End If
        End If
 
    End Sub



When i set the username textbox blank i get this screen.

 Picture 1

after i input my user name and set password blank. i already gives the same message.

 Picture 2

How i can fix this problem. can you give an example to fix this problem. i am new in  ajax.
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

abhinaypCommented:
If i am not wrong, i presume, in the aspx, u set the modalpopup extender 'TargetControlID' property to ur login button id.

If yes, remove that, create a dummy button somewhr else in ur page, set its display to none, n set the TargetControlID property of mpe to this button. This will prevent the modalpopup from openin in every click.



<asp:Panel ID="pnllogin" runat="server">
        <table>
            <tr>
                <td>
                    <label>
                        UserName</label>
                </td>
                <td>
                    <asp:TextBox runat="server" ID="txtUser"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        Pass</label>
                </td>
                <td>
                    <asp:TextBox runat="server" ID="txtPass"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Button runat="server" ID="btnLogin" OnClick="btnLogin_Click" />
                </td>
            </tr>
        </table>
    </asp:Panel>


                    <asp:LinkButton runat="server" ID="btnDummy" Style="display: none" />

    <asp:Panel ID="pnlError" BackColor="White" CssClass="PopupPanel" runat="server">
        <table>
            <tr>
                <td>
                    <label>
                        <b>Invalid Credentials</b></label>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:LinkButton ID="btnClose" runat="server" Width="90px" Text="Close" />
                </td>
            </tr>
        </table>
        <ajaxtool:ModalPopupExtender runat="server" ID="MPEError" TargetControlID="btnDummy"
            CancelControlID="btnClose" PopupControlID="pnlError" BackgroundCssClass="Fadedbackground"
            X="250" Y="200">
        </ajaxtool:ModalPopupExtender>
    </asp:Panel>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
adminenderAuthor Commented:
i made it how u said but it didn't make any change. i found a solution. i put my label into a updatepanel. after that my message text changed. thaks for your comments.
adminenderAuthor Commented:
Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.