Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi World :) I have a SPAN in my page which will change its text based on the selection I do in dropdown. Whenever I change the value in dropdown the span value gets changed based on the value I selected in dropdown, However the value appears only for 2-3 seconds (i.e only during page loading) and after page loading the SPAN text is getting blank. Not sure how to retain the span text even after page loading. please help me to overcome this issue.


Thanks in Advance and have a great day all :)
Posted
Updated 29-Jun-14 4:20am
v2
Comments
Please post the codes.
ZurdoDev 29-Jun-14 20:50pm    
You'll have to post the relevant code.
SRK90 2-Jul-14 23:04pm    
here is my java script :

<script type="text/javascript">
function validateTextbox() {
var textbox = document.getElementById('<%=textbox.ClientID%>');
var errormessagespan = document.getElementById('<=errorMessageSpan.ClientID>');
if (textbox.value == "") {
errormessagespan.innerHTML = "please enter the value for textbox1";
}
}

</script>


Here is my HTML coding :

<input type="text" id="textbox" runat="server" width="650px" height="100px" />
<br />
<span id="errorMessageSpan" runat="server" style="color : Red;" />
<input type="submit" value="Submit" runat="server" disabled="disabled" önclick="validateTextbox()" id="submitButton" />

I think this problem might be with the Mozilla Firefox. I had Came Across Same Issue. I had Solved this issue by converting Span To Div,

span.Content replaced by div.InnerHTML
 
Share this answer
 
Comments
SRK90 2-Jul-14 22:54pm    
I have done with DIV too... but still facing the problem :'(
Hi Guys, after doing some research and some self testing I have found the solution for this.
Since the page is getting page load after the click of submit button, the SPAN value is getting cleared. So i have returned false from my Javascript function. That is

C#
var errormessagespan = document.getElementById('<=errorMessageSpan.ClientID>');
 if (textbox.value == "") {
 errormessagespan.innerHTML = "please enter the value for textbox1";
 return false;
 }



and i have given my submit button onclick as

<input type="submit" value="Submit" runat="server" disabled="disabled" önclick=" return validateTextbox()" id="submitButton" />


Now the SPAN value is getting displayed properly and no more its getting cleared.

Thanks for putting your time and please do accept my solution if you feel it works fine for you.
Have a great day world :)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900