I have a page load event on view side where i want to display a string using window.open(). Since window.open() cannot be written directly under page_load I am building a string which contains window.open() syntax and which is passed further to RegisterStartupScript(). Actual URL passed to window.open will call a post method which will provide the data required to be printed.
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (ViewData["FileContents"] != null)
{
var viewDataValue = ViewData["FileContents"];
string js = "<script language='javascript'>";
js += "window.open('/Study/StudyConfiguration" + ViewData["FileContents"] + "','name','dialogWidth:100px');";
js += "</" + "script>";
RegisterStartupScript("StartupScript",js);
}
}
</script>
Whats happening right now with this is, only dialog gets displayed and not the string. Do let me know any correction to be made to solve the problem.
Thanks, Kapil