Behaviour of HTML/ASP controls in Master page
-
Sorry Chris, I might be asking similar type question earlier also but this is final summary. Suppose we have designed a master page. Say we keep nothing in it. We inherit it in a webform. Now I have observed the following. Please confirm,reply also: 1. <form> /<form> is not present. HTML Reset button works fine. Document.getelementbyid-> does not work because form is not present. 2. In web form where i have inherited master page, I keep one html reset button and standard asp text box. If autopostback of textbox=true then whatever we enter in textbox and click on reset, page load occurs.It will retain the values. Now value from text box will not be cleared after clicking on Reset. Because reset sets it back to inital value (that we got after page load). If autopostback of textbox=false then whatever we enter in textbox and click on reset, value will be cleared. 3. In my requirement i have inherited master page in web form as mentioned above. It's requirement to keep autopost back of textbox=True. Now reset will never clear the values of text box. In that case, if i use simple HTM button (not reset) and try to write the following code, it does not work because <form> is not present. So document will not be identified. function ResetForm(){ var elems = document.forms[0].elements; for(var i=0;i<elems.length;i++){ elems[i].value = ""; } } So in webform (using master page), how to clear the values of text box on clicking of button. Note: document will not work because <form> is not present. autopost back will be true for text box because we have to trigger event TextBox1_TextChanged1 also. TextBox1_TextChanged1 will not work without autopostback. So plz tell me solution.
-
Sorry Chris, I might be asking similar type question earlier also but this is final summary. Suppose we have designed a master page. Say we keep nothing in it. We inherit it in a webform. Now I have observed the following. Please confirm,reply also: 1. <form> /<form> is not present. HTML Reset button works fine. Document.getelementbyid-> does not work because form is not present. 2. In web form where i have inherited master page, I keep one html reset button and standard asp text box. If autopostback of textbox=true then whatever we enter in textbox and click on reset, page load occurs.It will retain the values. Now value from text box will not be cleared after clicking on Reset. Because reset sets it back to inital value (that we got after page load). If autopostback of textbox=false then whatever we enter in textbox and click on reset, value will be cleared. 3. In my requirement i have inherited master page in web form as mentioned above. It's requirement to keep autopost back of textbox=True. Now reset will never clear the values of text box. In that case, if i use simple HTM button (not reset) and try to write the following code, it does not work because <form> is not present. So document will not be identified. function ResetForm(){ var elems = document.forms[0].elements; for(var i=0;i<elems.length;i++){ elems[i].value = ""; } } So in webform (using master page), how to clear the values of text box on clicking of button. Note: document will not work because <form> is not present. autopost back will be true for text box because we have to trigger event TextBox1_TextChanged1 also. TextBox1_TextChanged1 will not work without autopostback. So plz tell me solution.
amittinku wrote:
<form> /<form> is not present.
your page is broken if this is true
amittinku wrote:
If autopostback of textbox=true then whatever we enter in textbox and click on reset, page load occurs.It will retain the values. Now value from text box will not be cleared after clicking on Reset. Because reset sets it back to inital value (that we got after page load). If autopostback of textbox=false then whatever we enter in textbox and click on reset, value will be cleared.
Because you don't have a form
amittinku wrote:
In that case, if i use simple HTM button (not reset) and try to write the following code, it does not work because <form> is not present. So document will not be identified.
Correct
amittinku wrote:
So in webform (using master page), how to clear the values of text box on clicking of button.
PUT A FORM ON THE PAGE !!!! And don't post a new question when your old one is still visible, and you're asking the same thing.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
amittinku wrote:
<form> /<form> is not present.
your page is broken if this is true
amittinku wrote:
If autopostback of textbox=true then whatever we enter in textbox and click on reset, page load occurs.It will retain the values. Now value from text box will not be cleared after clicking on Reset. Because reset sets it back to inital value (that we got after page load). If autopostback of textbox=false then whatever we enter in textbox and click on reset, value will be cleared.
Because you don't have a form
amittinku wrote:
In that case, if i use simple HTM button (not reset) and try to write the following code, it does not work because <form> is not present. So document will not be identified.
Correct
amittinku wrote:
So in webform (using master page), how to clear the values of text box on clicking of button.
PUT A FORM ON THE PAGE !!!! And don't post a new question when your old one is still visible, and you're asking the same thing.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
PUT A FORM ON THE PAGE !!!! I have inherited master page. Now I will have to paste controls on Content. Can we still post a form, there is so speciic control as such
-
Sorry Chris, I might be asking similar type question earlier also but this is final summary. Suppose we have designed a master page. Say we keep nothing in it. We inherit it in a webform. Now I have observed the following. Please confirm,reply also: 1. <form> /<form> is not present. HTML Reset button works fine. Document.getelementbyid-> does not work because form is not present. 2. In web form where i have inherited master page, I keep one html reset button and standard asp text box. If autopostback of textbox=true then whatever we enter in textbox and click on reset, page load occurs.It will retain the values. Now value from text box will not be cleared after clicking on Reset. Because reset sets it back to inital value (that we got after page load). If autopostback of textbox=false then whatever we enter in textbox and click on reset, value will be cleared. 3. In my requirement i have inherited master page in web form as mentioned above. It's requirement to keep autopost back of textbox=True. Now reset will never clear the values of text box. In that case, if i use simple HTM button (not reset) and try to write the following code, it does not work because <form> is not present. So document will not be identified. function ResetForm(){ var elems = document.forms[0].elements; for(var i=0;i<elems.length;i++){ elems[i].value = ""; } } So in webform (using master page), how to clear the values of text box on clicking of button. Note: document will not work because <form> is not present. autopost back will be true for text box because we have to trigger event TextBox1_TextChanged1 also. TextBox1_TextChanged1 will not work without autopostback. So plz tell me solution.
In Asp .net set the Text Box property EnableViewState="false" then ur prob are solve.........