Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to check if web page loaded

Posted on 2014-11-06
9
Medium Priority
?
59 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
TCP/IP Network Protocol Cheat Sheet

TCP/IP is a set of network protocols which is best known for connecting the machines that make up the Internet. The truth is that TCP/IP is one of the oldest network protocols and its survival is mainly based on its simplicity and universality.

 

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

How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

719 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