Opening jQuery Colorbox with ASP Button OnClick

I am still pretty new to using jQuery to do anything, but I have had good luck with linking to Colorbox iFrames in the past.

Right now, I am trying to link a common ASP button to open up a Colorbox window. I have tried searching all over but I can't seem to find the exact answer I'm needing. Here is what I have so far, which definitely doesn't work at all.

 <div id="openColorbox">
        <asp:Button ID="NewRecordBTN" runat="server" Text="New Material Movement Request" onclick="NewRecordBTN_Click" />
 </div>

 <script type="text/javascript">
    $(document).ready(function () {
        $("#openColorbox").click(function(){
            $.colorbox({ 
                  iframe: true, 
                   width: "80%", 
                  height: "80%", 
              transition: "fade" }));
    });

Trying to make the jQuery .click() function watch the "openColorbox" div that I created and open on click. I also want to point the iFrame to another URL in the process.

Answers


Try to handle OnClientClick event on button

EDIT:

Something like this:

 <asp:Button ID="New`enter code here`RecordBTN" runat="server" Text="New Material Movement Request" onclick="NewRecordBTN_Click" OnClientClick="OpenColorBox()" />


<script type="text/javascript">
  function OpenColorBox()
  {
    $.colorbox({ iframe: true, width: "80%", height: "80%", transition: "fade" });
  }    

</script>

I am not sure if you need server side event handling?


I was able to send to a URL within the jQuery Colorbox and reload the parent page after the transaction was completed via the following code:

 <script type="text/javascript">
    function OpenCBox() 
    {
        $.colorbox({ href: "NewMMR.aspx", iframe: true, width: "40%", height: "70%", transition: "elastic", onClosed: function () { parent.location.reload(true); } });
    }
</script>

This will reload the parent page upon reload. It also sends it to NewMMR.aspx when it is finished.


Need Your Help

Concat not work phpmyadmin (mysql)

sql phpmyadmin string-concatenation

i want update my row and concat my string but i have an error with this query

Maven - Dependency Resolution Failed, Package exists in local repo

java dependencies maven-3 dependency-management maven-gae-plugin

I am using maven-gae-plugin from http://code.google.com/p/maven-gae-plugin/ to create a multi-module project using inheritance (parent-project reference)