Popup window in same page and not in am empty page

        I am new to ASP.NET and C #.I am creating a web page with dynamically created textboxes.I submit these textbox values into the database.Before I click the Submit button I would like to check whether all the all the textbox values are entered and if any of the textbox is empty I would like to show a popup window stating that "Kindly enter all the values"
        This function works for me.But this popup window does not appear in the same page and it pops up in an empty background page and once I click OK i come back to my original page.
        I would like to have the pop up  window in my original page where I click the Submit Button and not an empty page.
        Can anyone help me to achieve this.

I used the code below
  if (tb.Text == String.Empty)
                      Response.Write("<script language='javascript'>alert('Kindly enter all the values')</script>");
                       return ;

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

thats probably because you are using response.write.

instead of that, use a common function that registers the alert function you wish to use in code behind.

for vb function:

Public Sub AlertError(ByVal ErrorStr As String)
        System.Web.UI.ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType(), "TestKey", "alert('" & ClearStrForJavaScript(ErrorStr) & "');", True)
End Sub

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
asudhaaAuthor Commented:
Thank for your answer.As you said the problem was due to response.write and with below code it works well

   string strScript = "<script language='JavaScript'>alert('Kindly enter all the values')</script>";
                        Page.RegisterStartupScript("PopUp", strScript);
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

From novice to tech pro — start learning today.