var txt= $("input[id$='txtShareMessage']").val(name);
If you will alert "
, you will get
. That is because it is a
actually and you are holding it in
You should read the value by...
See how it is working.
[Demo] Alert TextBox value after assigning Value to it