I created a form with two text boxes, when i reload the page those values are not getting refreshed..
Kindly help to clear the values of textboxes when the page is loaded.

Option which i used

Auto Post Back=False
Enable View State=False

>Kindly help to clear the values of textboxes when the page is loaded.

TextBox1.Text=String.Empty;  
...

Hey Thanks for your reply, my actual problem is - i am not able to clear the values of textboxes because i am adding the two values in the click event (i.e) after the pageload

I have entered my source code below:

=========================================

namespace Sample2
{
    public partial class _Default : System.Web.UI.Page
    {
        public void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            int value = Int32.Parse(TextBox1.Text) + Int32.Parse(TextBox2.Text);

            Label3.Visible = true;
            // Response.Write ("the result is" +value);

            Label3.Text = "The result is" + value;
           // Response.Redirect("//www.google.com");
            
            

            if (Page.IsPostBack == true)
            {
                
                TextBox1.Text = "";
                TextBox2.Text = "";
               

                //  Label3.Visible = false;

                // Label3.Text = "The result is" + value;
                //  Response.Write("HI");

            }
          

        }

=================================================

You code seems alright.

I know this is a 4 day old thread but I have never seen a check for (Page.IsPostBack) in a button_click event. I thought that you could only check for a postback in the Page_Load Event.

Am I wrong in thinking this?

>Am I wrong in thinking this?

You are right. The statement IsPostback in button's click event has no value at all.

ahhhmmm.... i don't know really know.. if it can help you..hehehe
but just try this one..
select in the event the activate and the object is form1..if you don't rename the form...between the private sub form1.activate
end sub...type the text1.text="" and text2.text=""
so the code will be...May God Bless you... i suggest that it is a good habit to rename the controls..

Welcome ragde51.

Please read OP and other subsequent posts. This is ASP.NET forum.

Also, you could mix some javascript in this.
<script lanague="javascript">
document.getElementById("<%=TextBox1.ClientID%>").value = "";
</script>

and call this in the onload.

Hi
I have a dropdownlist (ddl2) which is dependent on the selected value of another dropdownlist (ddl1).
I am not using databinding methods. Kindly prove the syntax for this dropdown list!!

again,i would use javascript for some thing like this
the first list you can use <select change="someFunction()">
then that function would act on the 2nd list

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.