Solved

How to check if web page loaded

Posted on 2014-11-06
9
47 Views
Last Modified: 2015-02-21
I have a vb.net page that has a iframe and a link button on it. When I click the link button I change the src of the iframe to  lets say "http://www.testlogin.com". Once test.login is loaded I want to enter a username and password using findcontrol.  My problem is I don't when the page has completed loading. How do I do this with an Iframe. I am not using the webbrowser control because I am not using windows forms. This is a web app.
Thanks
0
Comment
Question by:whiwex
  • 5
  • 4
9 Comments
 
LVL 27

Expert Comment

by:Ark
ID: 40429803
Once test.login is loaded I want to enter a username and password using findcontrol
Note that test.login is loaded on CLIENT while findcontrol is a SERVER function. You can use javascript on client
<script type="text/javascript">
document.getElementById('ifrm').onload = function() {
    // put your awesome code here
    // to call server function use web methods with HTTPRequest/Ajax
}
</script>

Open in new window

0
 

Author Comment

by:whiwex
ID: 40429812
Yes I don't know javascript very well so I want to do it using my server. I thought findcontrol would work but is doesn't.
0
 
LVL 27

Expert Comment

by:Ark
ID: 40429816
Since IFrame source doesn't exists on your server - you can not use findcontrol for IFrame
0
 

Author Comment

by:whiwex
ID: 40429829
what if I use runat='server'
Is there anyway to use the webbrowser control in a .net app. I can do what I want using a windows form and the webbrowser control. But not in my web form
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 27

Expert Comment

by:Ark
ID: 40429853
Code behind (on your aspPage.vb):
Imports System.Web.Services
Public Class YourPageName
    Inherits System.Web.UI.Page
    
    Private Class UserInfo
        Public Login As String
        Public Password As String
    End Class

   <WebMethod()>
    Public Shared Function GetUser() As UserInfo
        Dim ui As New UserInfo With {.Login = "MyLogin", .Password = "TopSecret"} 
        Return ui
    End Function
End Class

Open in new window

Javascript:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>
    <script type="text/javascript">
        $('#YourIFrameID').load(function(){
           if($('#YourIFrameID').attr('src').indexOf('testlogin.com')==-1) return;
           var params = {};
               $.ajax({
        type: "POST",
        url: location.pathName+"/GetUser",
        data: params,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {  
             var ui = data.d ? data.d : data;
             $("#YourIFrameID").contents().find("#loginField").text(ui.Login);
             $("#YourIFrameID").contents().find("#passwordField").text(ui.Password);
        },
        fail: function () { alert('Error'); }
    });
 
        });
    </script>

</head>
<body>
    <form id="form1" runat="server">
   </form>
</body>
</html>

Open in new window

0
 

Author Comment

by:whiwex
ID: 40429875
I added this but I doesn't work. I am using a master page. I'm not sure how to trigger the login and password.
0
 
LVL 27

Expert Comment

by:Ark
ID: 40429974
At any page add public shared function with WebMethod attribute (server side), which return Login/Password
  <WebMethod()>
Public Shared Function GetUser() As UserInfo

Open in new window

Then in client part (HTML) add javascript, calling above method (see my previous post). Url parameter should be in form:
url: 'pagePath.aspx/functionName', for example:
url: 'myPageWhereWebMethodIs.aspx/GetUser'

Open in new window

0
 

Accepted Solution

by:
whiwex earned 0 total points
ID: 40612954
I never fixed this
0
 

Author Closing Comment

by:whiwex
ID: 40622794
I never fixed this
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now