Button1_Click from js

  • Thread starter Thread starter hoz
  • Start date Start date
H

hoz

Hi , i have a button . how can i click it through java script ? like below
, but this doesnot work
<script type="text/javascript">

<!--

function Avs(s)

{

iframeWin.document.forms['Form1'].Button2.click();

iframeWin.document.forms['Form1'].submit();

}

-->

</script>
 
Do you really need to click the Button or are you just trying to postback
page without using a Button or Hyperlink?

Ralf
 
The click method you are using in :
iframeWin.document.forms['Form1'].Button2.click(); should work.

I've created a method as follows:
<script type="text/javascript">
function Call1(){
alert("button2 clicked");
window.document.forms['Form1'].Button2.click();
}
</script>


where Button2 is declared in the page as follows:
<asp:Button id="Button2" style="Z-INDEX: 103; LEFT: 216px; POSITION:
absolute; TOP: 296px" runat="server" Text="Button"></asp:Button>

When I call the method Call1, the button is clicked and its server side
event runs (in another sample, I made it show an alert message on client
side without postback and it worked).

Do you set the id of the button correctly? in the button declaration and
usage? Please check that there are no javascript errors that appear on the
page

Regards
Mohamed El Ashmawy
MEA Developer Support Center
ITWorx on behalf of Microsoft EMEA GTSC
 
I think i relate my problem wrong . Let me explain step by step .
I have an iframe , inside the iframe i have a button name Button1 .
In the page which contains iframe i have a link . That link must do the
following .
whenever i click link , it must behave as like button1 is clicked.
in the below code , it doesnt work
 
why don't you use the LinkButton Control for your link and assign the
Button1.Click eventhandling routine to its Click event, too?

hoz said:
I think i relate my problem wrong . Let me explain step by step .
I have an iframe , inside the iframe i have a button name Button1 .
In the page which contains iframe i have a link . That link must do the
following .
whenever i click link , it must behave as like button1 is clicked.
in the below code , it doesnt work

"Mohamed El Ashmawy" said:
The click method you are using in :
iframeWin.document.forms['Form1'].Button2.click(); should work.

I've created a method as follows:
<script type="text/javascript">
function Call1(){
alert("button2 clicked");
window.document.forms['Form1'].Button2.click();
}
</script>


where Button2 is declared in the page as follows:
<asp:Button id="Button2" style="Z-INDEX: 103; LEFT: 216px; POSITION:
absolute; TOP: 296px" runat="server" Text="Button"></asp:Button>

When I call the method Call1, the button is clicked and its server side
event runs (in another sample, I made it show an alert message on client
side without postback and it worked).

Do you set the id of the button correctly? in the button declaration and
usage? Please check that there are no javascript errors that appear on the
page

Regards
Mohamed El Ashmawy
MEA Developer Support Center
ITWorx on behalf of Microsoft EMEA GTSC
 
first , thanks for your anwser .finally you dont try to understand my
problem .

Ralf Müller said:
why don't you use the LinkButton Control for your link and assign the
Button1.Click eventhandling routine to its Click event, too?

hoz said:
I think i relate my problem wrong . Let me explain step by step .
I have an iframe , inside the iframe i have a button name Button1 .
In the page which contains iframe i have a link . That link must do the
following .
whenever i click link , it must behave as like button1 is clicked.
in the below code , it doesnt work

"Mohamed El Ashmawy" said:
The click method you are using in :
iframeWin.document.forms['Form1'].Button2.click(); should work.

I've created a method as follows:
<script type="text/javascript">
function Call1(){
alert("button2 clicked");
window.document.forms['Form1'].Button2.click();
}
</script>


where Button2 is declared in the page as follows:
<asp:Button id="Button2" style="Z-INDEX: 103; LEFT: 216px; POSITION:
absolute; TOP: 296px" runat="server" Text="Button"></asp:Button>

When I call the method Call1, the button is clicked and its server side
event runs (in another sample, I made it show an alert message on client
side without postback and it worked).

Do you set the id of the button correctly? in the button declaration and
usage? Please check that there are no javascript errors that appear on the
page

Regards
Mohamed El Ashmawy
MEA Developer Support Center
ITWorx on behalf of Microsoft EMEA GTSC
 
Back
Top