I’m starting on coding chat function in my web application. What I want is after user hitting send button, what they texted will be displayed in the chatting div immediately.
I use jQuery to perform this function, however, I found that after displaying the content, it disappears immediately. Did I miss something?
<script type="text/javascript">
function Send() {
var original = $('#contentDIV').html();
var text = $("[id$='TextBox1']").val();
$('#contentDIV').html(original + "<br />" + text);
}
</script>
<div id="contentDIV" style="height:400px;overflow:auto">
</div>
<input name="TextBox1" type="text" id="TextBox1" style="width:400px;" />
<input type="button" name="Button1" value="Button" onclick="Send();__doPostBack('Button1','')" id="Button1" />
This seems to be working. I made the JS unobstructive.
http://jsfiddle.net/eTRRP/
Sounds as if, however, you’ve got an issue with your ASP helper 🙂