Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello fellow programmers, Im a little confused right now on my coding so I am seeking your help. What I am trying to accomplish to execute my javascript from my master page on server side. Here is my code on javascript on show modal dialog (master page)
C#
function OpenPopup() {
            if (window.showModalDialog) {
                window.showModalDialog("PopUp.aspx", "PopUp",
"dialogWidth:550px;dialogHeight:300px,window.location = window.location;");
                window.location.reload();
            } else {
                window.open('PopUp.aspx', 'name', 'height=350,width=600,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes');

            }
        }
    </script>

Now I am trying to execute my javascript on code behind here is my trial code but so far nothing is working. Please help
VB
If e.CommandName = "cmdAdd" Then
           Dim addimage As ImageButton = DirectCast(e.CommandSource.FindControl("ImageAdd"), ImageButton)
           Dim coursecatId As String = addimage.CommandArgument
           Session("AddChecking") = "1"
           Session("AddCourseCatID") = coursecatId
           Session("AddYear") = drpdwnYear.Text
           Session("AddDiscipline") = DropDownList1.SelectedValue
           'addimage.Attributes.Add("onclick", "javascript:return OpenPopup()")

           'If (Not ClientScript.IsStartupScriptRegistered("OpenPopup")) Then
           'Page.ClientScript.RegisterStartupScript(Me.GetType(), "Popup", "OpenPopup();", True)
           'End If
           'Master.Page.ClientScript.RegisterStartupScript(Me.[GetType](), "OpenPopup", "window.showModalDialog('PopUp.aspx','','');", True)
           'dialogWidth:550px;dialogHeight:300px,window.location = window.location;
           'Dim script = "var $dialog = $('<div></div>').html('This dialog will show every time!').dialog({autoOpen: false,title: 'Basic Dialog'});$dialog.dialog('open');"
           'Master.Page.ClientScript.RegisterStartupScript(Me.GetType(), "OpenPopup();", script, True)
           'Dim script = ("OpenPopup();")
           'Master.Page.ClientScript.RegisterStartupScript([GetType](), Guid.NewGuid().ToString(), script, True)


       Else



note that addimage.attribute.add(...) is working but I have to double click which will kinda frustrate the user. I cannot use it on rowdatabound cause I need the sessions so what I really need is RegisterStartupScript.

thanks and more power
Posted
Comments
Sriram Chitturi 9-Feb-12 18:57pm    
Your posting is not clear. Why do you have commented code?
Do you want to know what part of the commented code you want to use? Is that your question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900