Solved

How to check if web page loaded

Posted on 2014-11-06
9
45 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

13 Experts available now in Live!

Get 1:1 Help Now