Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2008

Tip: Looking for answers? Try searching our database.

Using Invoke

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James - 14 May 2008 16:18 GMT
Hello everyone,
While loading a page
(http://www.edmonton.ca/portal/server.pt?space=CommunityPage&control=SetCommunity
&CommunityID=239
)
into a webbrowser control I use invokemember on the 'onclick' event from
'cmdBusStopScheduleSubmit' element - see below.

ONCLICK
=========
<input type="submit" name="cmdBusStopScheduleSubmit" value="Get Bus Stop
Schedule" id="cmdBusStopScheduleSubmit" class="formBtnText"
onclick="if (ValidateBusStopSchedule())
{
gfnTransit_SwitchPostBackUrl('BusStopSchedule.aspx|BusStopLookup.aspx','BusStopSchedule_Results.aspx','frmBusStopScheduleForm','_blank','NOVIEWSTATE');
}
else {
return false;
}"
style="height:40px;width:155px;" />

FUNCTIONS
===========
I have located the two functions inside the onclick event:

function RouteSchedulePostBack(eventTarget, eventArgument,strFormName,
strTargetField, strTargetValue)
{
        var theform = document.forms[strFormName];
        theform.__EVENTTARGET.value = eventTarget.replace(/\$/g, ":");
        theform.__EVENTARGUMENT.value = eventArgument;
        //check if value needs to be passed through to form submit
        if (strTargetField != '')
            theform[strTargetField].value = strTargetValue;
        theform.submit();
}

function gfnTransit__doPostBack(eventTarget, eventArgument, strFormName) {
        var theform = document.forms[strFormName];
        theform.__EVENTTARGET.value = eventTarget;
        theform.__EVENTARGUMENT.value = eventArgument;
        theform.submit();
    }

The page does not refresh nor does it load any other page. However, if I use
Focus and have the cmdBusStopSchedule focused, I can press the space bar and
it will work as planned. If I leave the Bus Stop field empty, I get an alert
with either method - Invokemember or focus/space bar.

It must be the gfnTransit or the RouteSchedulePostBack functions. What I do
not understand is why the Focus and Space bar makes a difference? Is it
possible to remove the onclick event and put in my own? I just want the
BusStopSchedule.aspx to run.

Would it be best to find a javascript form?

Any thoughts would be apreciated...

-James
Alvin Bruney [ASP.NET MVP] - 14 May 2008 19:59 GMT
The terms you are using are very confusing. Web browser control is typically
a windows browser control used to navigate a web page, Invoke as well is
something different than what you use here. Point is, after looking at the
code, I think you are referring to an ordinary web page and a web control
right? If that's the case, your if statement is evaluating to false on the
first call. When you press spacebar it is evaluating to true. Why? You'd
need to debug ValidateBusStopSchedule() to find the reason.

Signature

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------

> Hello everyone,
> While loading a page
[quoted text clipped - 53 lines]
>
> -James
James - 14 May 2008 22:12 GMT
Thanks for your reply Alvin,
I am using a web browser control. I am using the InvokeMember method. The
problem is I cannot dig deeper into the web page as it is not mine - just
public access. Was thinking about something like:

cmdFirst.Attributes.Remove("onclick")
cmdFirst.Attributes.Add("onclick", "BusStopSchedule_Results.aspx")

I suspect this would fail as I would need access rights to Remove/Add a new
onclick event. Do you think it would be possible to setup a delagate for the
onclick to insure the BusStopSchedule.aspx is run (MyClick.Invoke)?

Have you used either method successfully on a public webpage?

> The terms you are using are very confusing. Web browser control is
> typically a windows browser control used to navigate a web page, Invoke as
[quoted text clipped - 63 lines]
>>
>> -James
Alvin Bruney [ASP.NET MVP] - 17 May 2008 02:57 GMT
So you have a webbrowser control that loads someone else's page and when a
button on that web page is clicked, you want it to run your code? Did I get
that right? That's an odd request. You can't attach to their handler because
the events aren't exposed to you. hmm, I'm lost here. totally.

Signature

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------

> Thanks for your reply Alvin,
> I am using a web browser control. I am using the InvokeMember method. The
[quoted text clipped - 78 lines]
>>>
>>> -James
James - 19 May 2008 21:38 GMT
Sorry for the late reply Alvin. Comes down to the scripts the webmaster is
running. I get two different results. 1) clicking mouse, new page loads with
info; 2) using the invokemember I get nothing. However, there is a
validation function that runs first, using either method that works.

I have given up an sent them an email to see if web-services are in their
future... the webpage is for a local bus transit schedule.

Thanks for you assistance Alvin, and again sorry for the late reply.

> So you have a webbrowser control that loads someone else's page and when a
> button on that web page is clicked, you want it to run your code? Did I
[quoted text clipped - 85 lines]
>>>>
>>>> -James

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.