Reputation: 21
I am using the <%= %>
syntax for passing the html control textarea id in the JavaScript function. I have a problem that after saving the my aspx page when I run the page it runs successfully but after some it automatically disappears from the html code.
sombody can explain the above syntax and why it disapear from the source code after a given time
here is the code
before execute i write code and save.
<textarea id="txtmsgchar"
cols="20"
name="txtmsgchar"
onkeyup="return taCount(this,'<%= lblcharcount.ClientID %>','<%= lbltotalmsg.ClientID %>')"
rows="10"
style="width: 477px; height: 111px">
</textarea>
After some time or when I open the project next time then I find the below code
<textarea id="txtmsgchar"
cols="20"
name="txtmsgchar"
onkeyup="return taCount(this,'','')"
rows="10"
style="width: 477px; height: 111px">
</textarea>
Please tell me why the given output comes
Upvotes: 2
Views: 182
Reputation: 57189
After some time or when i open the project next time then i find the below code
That doesn't seem to be possible unless you don't save, or unless you look at the code-view from a browser (i.e., after the page is rendered). Another thought might be that you're inside a version control system connected to an auto-build environment, which may rollback your changes if they contain compile errors (but I doubt that any build environment does so automatically).
Regardless, your issue has nothing to do with the <%= >
itself, which simply interprets the expression on server side and outputs its value.
Update: perhaps your issue is the following: if the controls lbltotalmsg
or lblcharcount
are invisible (server-side Visible="False"
), they are not rendered to the client side and hence will have an empty ClientId
.
Upvotes: 1
Reputation: 7248
It is server code that is executed. The expression is replaced by the value of lbltotalmsg.ClientID.
The result that is sent to the client is therefor something like this:
','some-client-id')" rows="10" style="width: 477px; height: 111px">
Upvotes: 1