Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to check if web page loaded

Posted on 2014-11-06
9
Medium Priority
?
65 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 28

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 28

Expert Comment

by:Ark
ID: 40429816
Since IFrame source doesn't exists on your server - you can not use findcontrol for IFrame
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

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
 
LVL 28

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 28

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

885 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