Using Invoke

J

James

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
 
A

Alvin Bruney [ASP.NET MVP]

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.

--

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


James said:
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
 
J

James

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?






Alvin Bruney said:
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.

--

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


James said:
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
 
A

Alvin Bruney [ASP.NET MVP]

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.

--

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


James said:
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?






Alvin Bruney said:
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.

--

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


James said:
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
 
J

James

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.





Alvin Bruney said:
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.

--

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


James said:
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?






Alvin Bruney said:
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.

--

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
(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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top