[RESOLVED] Open a popup window to print after sql insert

What I want is to pop up a window that is 100 x 100 after I do a sql insert and then print the page.  In 1.1 it worked greate but in VS 2010 it seems not to work great always get errors.  So this is what I am doing.

When user clicks on submit it rotates through a gridview ans saves data to a sql table.  After this i want to open a small popup window and have the print options open with it, print the page and then it closes window on print.  Here is where I am having trouble, the popup always gives me errors, i am using an update panel and I don't know if this is the problem or not.

For Each row As GridViewRow In myGridAdmin.Rows
            Dim AQuesId As Integer = myGridAdmin.DataKeys(row.RowIndex).Value
            Dim Adata As TextBox = TryCast(row.FindControl("txtAData"), TextBox)
            Dim ARemarks As TextBox = TryCast(row.FindControl("txtARemarks"), TextBox)
            Dim ADtdate As TextBox = TryCast(row.FindControl("txtACal"), TextBox)
            Dim Aanswer As RadioButtonList = TryCast(row.FindControl("rblAdmin"), RadioButtonList)


            sql = "Insert tblSRpEventData (intPersonnelId, intUnitSRPId, intQuestionId, bitAnswer, strData, strRemarks, dtDoc, dtLogged, strlogged) VALUES (" & PersId & ", " & UnitID & ", " & AQuesId & ", " _
                    & "" & Aanswer.SelectedValue & ", '" & Adata.Text & "', '" & ARemarks.Text & "', '" & ADtdate.Text & "', '" & Date.Today & "', '" & userlogon & "')"


            insertUpdateDelete(sql)
        Next


        Dim ssn As String = PersId
 

        ClientScript.RegisterClientScriptBlock(Me.[GetType](), "open", "<script type='text/javascript' window.open('" + Request.ApplicationPath & "../Reports/SRpIsses.aspx?ID=" & ssn & "','Width=100,height=100');</script>")


 

kldeutsch

i am using an update panel

Try using ScriptManager instead.

ScriptManager.RegisterStartupScript(Page, Me.GetType(), "open",
                                    "window.open('" + Request.ApplicationPath & "../Reports/SRpIsses.aspx?ID=" & ssn & _
                                    "','Width=100,height=100');"True)

I am still getting an error when opening the link. this is where it point to. this is the source view of the code. <script type="text/javascript"> //<![CDATA[ (function() {var fn = function() {$get("ToolkitScriptManager1_HiddenField").value = '';Sys.Application.remove_init(fn);};Sys.Application.add_init(fn);})();window.open('/ReadinessTracker/Reports/SRpIssues2.aspx?ID=12','Width=100,height=100');//]]> <

Hi,

It seems that the window.open javascript is not correct.

kldeutsch

"<script type='text/javascript' window.open('" + Request.ApplicationPath & "../Reports/SRpIsses.aspx?ID=" & ssn & "','Width=100,height=100');</script>

It should be:

<script type='text/javascript'> window.open('" + Request.ApplicationPath & "../Reports/SRpIsses.aspx?ID=" & ssn & "','PopWindow','Width=100,height=100');</script>

Also you can try this:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim url As String = Request.ApplicationPath & "../Reports/SRpIsses.aspx?ID=" & ssn
        Dim Script As String = "window.open('" + url + "', 'Popup', 'height=100,width=100');"

        Me.ClientScript.RegisterClientScriptBlock(Me.GetType(), "PopWindow", Script, True)
        'The button isn't in updatpanel

        ScriptManager.RegisterStartupScript(Page, Me.GetType(), "PopWindow", Script, True)
        'The button in updatpanel
    End Sub

 

Hope this can help you.

thoughts on "[RESOLVED] Open a popup window to print after sql insert"

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>