Solved

How to check if web page loaded

Posted on 2014-11-06
9
53 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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