So, I have this jquery function.
<script type="text/javascript">
$(document).ready(function () {
$('#answ').hide();
$("#btnsubmit").click(function () {
var tbans = $('<%= txtMain.ClientID %>').val();
alert(tbans);
$('#answ').toggle();
return false;
});
});
</script>
<textarea id="txtMain" runat="server" rows="20" cols="150" ></textarea>
<input type="submit" id="btnsubmit" />
Now, when I click on submit button, instead of showing the text written in textarea it shows alert that says,"undefined". Toggle function works though.
What I am missing?
P.s I am using tinymce texteditor plugin with my textarea.
UPDATE 1:
I tried using asp button like this.
<asp:Button ID="btnsubmit" runat="server" Text="Submit" Font-Bold="True"
CssClass="style10" BackColor="Gainsboro" Font-Size="Medium"
ToolTip="Submit Answer." UseSubmitBehavior="false" /><br />
then it shows the value of textarea in alert on click of Submit button and toggle works. But then page refreshes and toggle disappears. Also, if I remove UseSubmitBehavior="false" from button then page doesnt refresh but again, it doesnt show me the value of textarea.
UPDATE 2: I am using tinyMce texteditor with my textarea. tinymce is a well known texteditor. I checked removing tinymce and then code worked. But thing is, the code even worked with tinymce when I took asp.net button with UseSubmitBehavior="false", just it refreshed the page after clicking submit button.