0

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

5
Contributors
10
Replies
11
Views
7 Years
Discussion Span
Last Post by YanivC
0

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

TextBox1.Text=String.Empty;  
...
0

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");

            }
          

        }

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

Edited by __avd: Added [code] tags. Encase your code in: [code] and [/code] tags.

1

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?

0

>Am I wrong in thinking this?

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

0

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..

0

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

and call this in the onload.

0

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!!

-1

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.