Reputation: 957
I have a single line code that displays JS alert right now. I am trying to replace it with the jQuery alert so that I can theme it. Below is the code that I wrote for jQuery alert:
ScriptManager.RegisterStartupScript(this, GetType(), "onload",
"window.onload = function () {jAlert('This is a custom alert box', 'Alert Dialog');}", true);
This code used to be like this:
ScriptManager.RegisterStartupScript(this, GetType(), "showalert",
"alert('This is a custom alert box');", true);
The existing code works fine. But my code gives me an error saying,
value of property jalert is null
I am unsure, what I am missing here.
Upvotes: 0
Views: 419
Reputation: 6764
You're running an external plugin to JQuery.
Make sure that on your page you have valid references to the jquery
library and jalert
plugin.
The $.browser
property is considered obsolete and should not be used anymore. This is because there are a lot of browsers that misidentify about whom they are. IE12, for instance, identifies itself as a Mozilla browser.
You can find more information about the $.browser
property here.
If your version is JQuery 1.8 and under use this:
<!-- Dependencies -->
<script src="jquery.js" type="text/javascript"></script>
<!-- Core files -->
<script src="jquery.alerts.js" type="text/javascript"></script>
<link href="jquery.alerts.css" rel="stylesheet" type="text/css" media="screen" />
If your version is JQuery 1.9 and over, you'll need to reference the jquery-migrate.js
file so that you can use the $.browser
property:
<!-- Dependencies -->
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery-migrate.js" type="text/javascript"></script>
<!-- Core files -->
<script src="jquery.alerts.js" type="text/javascript"></script>
<link href="jquery.alerts.css" rel="stylesheet" type="text/css" media="screen" />
Upvotes: 1