0

I'm having two buttons and one button is hidden. Now when I click the visible button I need to do two things

1.Open Iframe.

2.Automatically make the 2nd Button(Hidden)to be clicked.

When the second button is clicked I need to display the message on top of the IFrame which I have mentioned as function showStickySuccessToast()

Now I am able to open IFrame but I'm unable to make the Hidden button clicked automatically.

This is what I'm having:

      <script type="text/javascript">
       $(document).ready(function(){
        $("#<%=Button1.ClientID%>").click(function(event){
            $('#<%=TextBox1.ClientID%>').change(function () {
                $('#various3').attr('href', $(this).val());
            });
    });
       function showStickySuccessToast() {
        $().toastmessage('showToast', {
            text: 'Finished Processing!',
            sticky: false,
            position: 'middle-center',
            type: 'success',
            closeText: '',
            close: function () {

            }
        });
    }
    }) 
    </script>

Here are my two buttons how I'm working with:

<a id="various3" href="#"><asp:Button ID="Button1" 
runat="server" Text="Button" OnClientClick="Button2_Click"/></a>

<asp:Button ID="Button2" 
runat="server" Text="Button" Visible="False" OnClick="Button2_Click"/>

And in the button2_Click event:

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
       System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "Script", "showStickySuccessToast();", True)
    End Sub
2
  • Any reason you couldn't use UpdatePanels? Commented Nov 21, 2011 at 19:17
  • I haven't tried yet with the update panels just I was trying with simple way to acheive this and further I'm planning to use the update panels and Is it good to use here in this application?May be I need most of your suggestions to make my application to work in a better way. Commented Nov 21, 2011 at 19:26

2 Answers 2

2

Put this inside the click event for your first (visible) button:

$("#<%=Button1.ClientID%>").click(function(event){
       $('#<%=TextBox1.ClientID%>').change(function () {
             $('#various3').attr('href', $(this).val()); 
       });
       $("#<%=Button2.ClientID%>").click();
});
3
  • First thanks for the reply and If I do this It gives me error as server tag is not well formed. Commented Nov 21, 2011 at 17:53
  • That is formed the same as your other click event (just with a different ID). Maybe rebuild? I'm not sure why that would cause an error. Commented Nov 21, 2011 at 17:55
  • @ Nate-Thanks I rectified my error and thanks for solving out my problem. Commented Nov 21, 2011 at 18:01
0
  <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script> 
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" />
           <script type="text/javascript">
               $('#Button1').click(function () {
                   if ($('#TextBox1').val() == '') {
                       alert("Error")
                       $('#TextBox1').focus();
                       return false;
                   }
               });
</script>
    </div>    
    </form>
</body>
</html>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.