Hi, I want to execute a function on loading the partial view. I have my partial view as follows. I am trying to call the function from script. But I think I can not use ViewData in my script. I don;t know proper way to use viewdata in script. Is there any way to access the viewdata inside script.
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<clsAdministration>" %>
<script language="javascript" type="text/javascript" for="window" event="onload">
InitializeView(ViewData["RoleErrMessage"]);
</script>
<script type="text/javascript" language="Javascript">
function InitializeView(msg) {
if (msg.toString().length > 0) {
alert(msg);
}
}
</script>
Thanks, Kapil