jazzIIIlove
asked on
inject aspx code to javascript or how to reach postback in javascript?
Hi;
I am trying to reach postback in front in javascript and inject the given html
or how can i reach postback in front?
I also add the Client register code but failed to operate it..
Regards.
I am trying to reach postback in front in javascript and inject the given html
<asp:PlaceHolder ID="myPlaceholder" runat="server">
<script type="text/javascript">
if(<%= Page.IsPostBack()%>) /// Fails here
{
document.write("<!DOCTYPE html>");
document.write("<html>");
document.write("<head>")
document.write("<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>");
alert("postback");
}
or how can i reach postback in front?
I also add the Client register code but failed to operate it..
Regards.
For a pure javacript solution (No server variables required)
<script type="text/javascript">
function isPostBack()
{
return document.referrer.indexOf(document.location.href) > -1;
}
if (isPostBack()){
//Your code goes here
alert("postback");
}
ASKER
Hi guru_sami;
The thing is that the code works but once it is postback, it's already too late that i cannot set DOCTYPE. Is there a way for this?
The thing is that the code works but once it is postback, it's already too late that i cannot set DOCTYPE. Is there a way for this?
<script type="text/javascript">
var postback = '<%= Page.IsPostBack%>';
alert(postback);
if (postback == 'True')
{
document.write("<!DOCTYPE html>");
document.write("<html>");
document.write("<head>")
document.write("<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>");
}
ASKER
mas_oz2003:
Same for you too.
Guys, the thing is i have an if check in codebehind, if it's not postback, i have to set to the doctype to another type.
That's the reason of this hassle.
Regards.
Same for you too.
Guys, the thing is i have an if check in codebehind, if it's not postback, i have to set to the doctype to another type.
That's the reason of this hassle.
Regards.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window