visual studio 2010 + webbrowser1 call javascript

Call Me.WebBrowser1.Document.InvokeScript("javascript:ChangePage1")

How can i use this in the proper format?

I need to call the javascript to change a page
mphillip85Asked:
Who is Participating?
 
Bob LearnedCommented:
This is what I was talking about:


private void AttachToCrystalReportPrintButtonEventHandler()
    {
        Control toolbar = this.CrystalReportViewer1.Controls[2];

        Control printButton = toolbar.Controls[1];

        EventInfo clickEvent = printButton.GetType().GetEvent("Click");

        MethodInfo method = clickEvent.GetAddMethod();

        ImageClickEventHandler handler = new ImageClickEventHandler(this.ImageClick);

        object result = method.Invoke(printButton, new object[] { handler });
    }

Open in new window

0
 
mphillip85Author Commented:
I am trying to just access a javascript in an aspx page.

i need to call the below function to change to the next page, what can i do
What can I do exactly?

function ChangePage1(id, selectedPage, startPage, ObjListID, ObjListProp, PageListID, PageListProp)
{
    document.forms["StatusForm"].page1.value = selectedPage;
    document.forms["StatusForm"].StartPage1.value = startPage;
    document.forms["StatusForm"].ObjListID1.value = ObjListID;
    document.forms["StatusForm"].ObjListProp1.value = ObjListProp;
    document.forms["StatusForm"].PageListID1.value = PageListID;
    document.forms["StatusForm"].PageListProp1.value = PageListProp;
    document.forms["StatusForm"].submit();
0
 
Bob LearnedCommented:
Is there an action associated with an element, such as a button, that calls the change page script, on the page?
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
mphillip85Author Commented:
there is a  hyperlink called [Next]
0
 
Bob LearnedCommented:
I would get a reference to the anchor element.  You can use the Microsoft.mshtml class to parse the WebBrowser.Document.DomDocument instance, using getElementById or getElementsByTagName, and then call the "click" method for the mshtml.HTMLAnchorElement instance.
0
 
mphillip85Author Commented:
i did an invoke a click on the element and also called the script to envoke the page change.
no luck
0
 
mphillip85Author Commented:
so i tried this

Call Me.WebBrowser1.Document.InvokeScript("javascript:ChangePage1")

How can i use this in the proper format?

I need to call the javascript to change a page
0
 
Bob LearnedCommented:
Did you try Me.WebBrowser1.Document.InvokeScript("ChangePage1")
0
 
mphillip85Author Commented:
yes
0
 
Bob LearnedCommented:
Then, you have other problems.  If you look at the document for the InvokeScript method, all you need is the JavaScript function that you are trying to call.

WebBrowser.InvokeScript Method (String)
http://msdn.microsoft.com/en-us/library/cc491132.aspx
Private Sub callScriptFunctionNoParamButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    ' Make sure the HTML document has loaded before attempting to
    ' invoke script of the document page. You could set loadCompleted
    ' to true when the LoadCompleted event on the WebBrowser fires.
    If Me.loadCompleted Then
        Try
            Me.webBrowser.InvokeScript("JavaScriptFunctionWithoutParameters")
        Catch ex As Exception
            Dim msg As String = "Could not call script: " & ex.Message & vbLf & vbLf & "Please click the 'Load HTML Document with Script' button to load."
            MessageBox.Show(msg)
        End Try
    End If
End Sub

Open in new window

0
 
mphillip85Author Commented:
i will try tomorrow again
thanks
0
 
mphillip85Author Commented:
i am still workin on it.
0
 
mphillip85Author Commented:
did not work.  do you need the viewsource code of the page i am trying to execute the call from ?
0
 
Bob LearnedCommented:
That would be a good start to finding out if it is even possible...
0
 
mphillip85Author Commented:
<!--

                    (c) Business Objects 2004. All rights reserved.

-->

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<HTML>

    <HEAD>

        <title>

            Instance Manager

        </title>

        <link rel='stylesheet' type='text/css' name='stylelink' href='/businessobjects/enterprise115/WebTools/websamples/InstancesByStatus/css/default.css'>

 

        <script Language="JavaScript">

 

function deleteSelected(numItems, qStr, owner) {

    var items = getSelected(numItems);

    if (items != "") { // if items are checked

        if(window.confirm("_Delete the selected item(s)?")) {

            window.location="main.aspx?framework=" + "" + "&queryString=" + qStr + "&owner=" + escape(owner) +"&del=true&display=true&ids=" + escape(items) + "";

        }

    } else {

        alert("_No items have been selected yet.");

    }

}

 

function selectAll(numItems) {

    for (var i = 1; i <= numItems; i++) {

        document.form1.elements["chkbox"+i].checked = true;

    }

}

 

function clearAll(numItems) {

    for (var i = 1; i <= numItems; i++) {

        document.form1.elements["chkbox"+i].checked = false;

    }

}

 

function getSelected(numItems) {

    // creates a string of id's delimited by " OR SI_ID="

    var items = "";

    for (var i = 1; i <= numItems; i++) {

        if(document.form1.elements["chkbox" + i].checked) {

            if (items != "") {

                items += ", ";

            }

            items +=document.form1.elements["chkbox" + i].value;                

        }

    }

    return items;

}

 

function submitFilter() {

    if (document.forms["StatusForm"].user.value == "" &&

                                document.forms["StatusForm"].status.selectedIndex == 0)        // all statuses

    {

        alert("Please enter a user name.");

        return;

    }

                if(document.forms["StatusForm"].indexstring)

                                document.forms["StatusForm"].indexstring.value = "";

    document.forms["StatusForm"].submit();

}

 

function ShowReport(id) {

    windowprops = "height=450,width=600,location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes";

    reportWindow = window.open("viewreport.aspx?init=connect&id=" + id, "rptWindow", windowprops);

}

 

function ShowOtherFormats(id) {

                windowprops = "height=450,width=600,location=no,scrollbars=no,menubars=no,toolbars=no,resizable=yes";

                wcsid = "";

                reportWindow = window.open("Otherobjectviewer.aspx?WCSID="+wcsid+"&id="+id, "rptWindow", windowprops);

}

 

function ShowWithScrollBars(id) {

                windowprops = "height=450,width=600,location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes";

                wcsid = "";

                reportWindow = window.open("Otherobjectviewer.aspx?WCSID="+wcsid+"&id="+id, "rptWindow", windowprops);

}

 

function goPage(page)

{

    document.forms["StatusForm"].action = document.forms["StatusForm"].action + "&page=" + page;

    document.forms["StatusForm"].submit();

}

 

// change page for folder list part

function ChangePage1(id, selectedPage, startPage, ObjListID, ObjListProp, PageListID, PageListProp)

{

    document.forms["StatusForm"].page1.value = selectedPage;

    document.forms["StatusForm"].StartPage1.value = startPage;

    document.forms["StatusForm"].ObjListID1.value = ObjListID;

    document.forms["StatusForm"].ObjListProp1.value = ObjListProp;

    document.forms["StatusForm"].PageListID1.value = PageListID;

    document.forms["StatusForm"].PageListProp1.value = PageListProp;

    document.forms["StatusForm"].submit();

}

 

        </script>

    </HEAD>

    <body>

        <form name='StatusForm' method='post' action='main.aspx?framework=&del=false&display=true&ids='><table width='100%' border='0' cellpadding='4' cellspacing='0'><tr><td class='header'>Welcome, Administrator!<br></td><td align='right' class='header'><a class='header' href='Rlogon.aspx?action=exit'>Exit</a></td></tr></table><br><table width='100%' border='0' cellpadding='4' cellspacing='0'><tr><td align='left' class='headerTitle'>Instance Manager</td><td align='right'><table cellspacing='0' cellpadding='2' border='0'><tr><td valign='middle' class='listSelected'>Status</td><td valign='middle'><SELECT name='status'><OPTION value='all'>All Statuses<OPTION SELECTED value='1'>Success<OPTION value='3'>Failed<OPTION value='9'>Pending<OPTION value='0'>Running<OPTION value='12'>Recurring<OPTION value='8'>Paused</SELECT></td><td class='listSelected' valign='middle'> by user </td><td valign='middle'><INPUT type='text' name='user' size=20 value=''></td><td valign='middle'><table align='right'><tr><td class='clsButton' align=middle nowrap><div class='clsButton'><a href='javascript:submitFilter();'>Go!</a></div></td>

</tr></table></td></tr></table></td></tr></table><hr size='1'><table align=left width='100%' cellspacing='0' cellpadding='4' border='0'><tr><td class='listHeading' align=left>Instances - Success : </td></tr></table><br><br>

<input type='hidden' name='page1' value=1>

<input type='hidden' name='ObjListID1' value=0>

<input type='hidden' name='ObjListProp1' value=''>

<input type='hidden' name='PageListID1' value=0>

<input type='hidden' name='PageListProp1' value=''>

<input type='hidden' name='StartPage1' value=1>

</form>

<table class='list' width='100%' cellspacing='0' cellpadding='3' border='0'><form name=form1 method=POST><th align=left class='list'>   </th><th align=left class='list'>Name</th><th align=left class='list'>Date</th><th align=left class='list'>Path</th><th align=left class='list'>Run Time<br>(seconds)</th><th align=left class='list'>Run By</th><th align='left'><table align='right'><tr><td class='clsButton' align=middle nowrap><div class='clsButton'><a href='javascript:deleteSelected(100,"1", "");'>Delete</a></div></td>

<td class='clsButton' align=middle nowrap><div class='clsButton'><a href='javascript:selectAll(100);'>Select All</a></div></td>

<td class='clsButton' align=middle nowrap><div class='clsButton'><a href='javascript:clearAll(100);'>Clear All</a></div></td>

</tr></table></th><tr><td class='history'>1. </td><td class='history'><a href='javascript:ShowOtherFormats("94771");'>Notes1</a></td><td align=left class='history'>4/22/2010 1:41 PM</td><td align=left class='history'>Home </td><td align=center class='history'>63.317</td><td align=left class='history'>tu</td><td align=center><input type='CHECKBOX' name = chkbox1 value=94771></td></tr><tr><td class='history'></table></form><table width='100%'><tr><td class='listSelected' align='right'>

1 <a href='javascript:ChangePage1(0,2,1,101114,"xx",0,"")'>2</a> <a href='javascript:ChangePage1(0,3,1,93237,"xx3",0,"")'>3</a> <a href='javascript:ChangePage1(0,4,1,100142,"xx4",0,"")'>4</a> <a href='javascript:ChangePage1(0,2,1,101114,"xx5",0,"")'>[Next]</a>

</td></tr></table>

<br><br>

        <FONT face="Arial"></FONT>

    </body>

</HTML>


--------------------------------------------------------------------------------

 

0
 
Bob LearnedCommented:
That looks like you are working with Crystal Reports, and you are trying to get a reference to the Next Page button, and click that.  What version of Crystal Reports are you working with?
0
 
mphillip85Author Commented:
XI
0
 
Bob LearnedCommented:
You have Crystal Reports in an ASP.NET web site, with the Crystal Report Viewer, right?  Are you doing straight forward report viewing?  I believe that I have a way of getting a reference to the controls on the toolbar, but I need to make sure that you are using the viewer in a standard environment.  I only have Visual Studio.NET 2010 installed now, so if you have XI that would be Visual Studio 2008, so I won't be able to test anything.
0
 
mphillip85Author Commented:
i have 2010 installed.  But the XI is the Business Objects Crystal reports server that I am web browsing to to get the information.
0
 
mphillip85Author Commented:
this is a regular webbrowser from 2010 that I point to a business objects server and retrieve a list of crystal reports that have ran and their status.  I am not using the crystal report viewer or need it.  So, i am not sure what the code above, how it can help me?  I do appreciate that you are trying to solve my problem.  Thank You.

0
 
mphillip85Author Commented:
I appreciate your efforts
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.