Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code problem

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
Trying to convert online the following c sharp code to vb and getting the error

CONVERSION ERROR: Code could not be converted. Details:

-- line 1 col 11: invalid TypeDecl

Code:
protected void Page_Load(object sender, EventArgs e)
{
  string scriptString = "<script language="JavaScript"> " + 
         "window.opener.document.forms(0).submit(); </script>";

  // ASP.NET 2.0
  if (!Page.ClientScript.IsClientScriptBlockRegistered(scriptString))
  {
    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), 
                                       "script", scriptString);
  }

  //// ASP.NET 1.X
  //if (!Page.IsClientScriptBlockRegistered(scriptString))
  //{
  // Page.RegisterClientScriptBlock("script", scriptString);
  //}

  if (!Page.IsPostBack) { }
  }
 
I believe the problem is with the scriptString value. You have to escape the quotes (") around Javascript
 
jbenson001,

Thank you for your replies as ever.

I will take a look at the link you sent me.

Essentially what I am trying to do is refresh a grid on a parent form from a jquery modal popup window.

The user adds record in the popup, window closes and grid refreshed.

If you know of any articles with samples that would be great.

Thanks

Andrew
 
This goes in the calling page of the pop up window:
Code:
this codes in the HTML of your page
function myRefresh()
{
   //Writes out the __doPostback call to the page.  This is called when the pop-up window is closed to refresh the screen.
   //The pop-up window calls this function, which in turn calls the Click event of the btnHiddenRefresh button.
   // __doPostBack('thisPage:btnHiddenRefresh','');
   <%=strRefresh %>;
}

 <asp:Button ID="btnHiddenRefresh" runat="server" />
In the code behind:
Code:
'Global variable
Public strRefresh As String

  Protected Sub btnHiddenRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHiddenRefresh.Click
        'This is a hidden button.  The click event is fired when the pop-up window is closed.
        '//The pop-up window calls the JS MyRefresh() function, which in turn calles this through the __doPostBack() call.
         '' Do your database call here and refresh the control.
    End Sub
If you already have code set up to do the database call and refresh, use that above instead of creating a new button

This code goes in the pop up window. It calls the code on the calling page that refreshes the data.
In my example I have a hyperlink that closes the popup and calls the code on the calling page to do a refresh:
Code:
 Me.lnkClose.HRef = "javascript:window.opener.myRefresh();window.close();"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top