mcrmg
asked on
colorbox question
Hi,
I am using colobox
http://www.jacklmoore.com/colorbox/
Is there a way to do the same thing from javascript? What I am doing is using GridView in a .net and use LinkButton to send the ID back to code behind, then send back that ID back to .net Javascript to use Colorbox
Sorry, I am sure there are better ways. But this is the only way I know..thanks
I am using colobox
http://www.jacklmoore.com/colorbox/
<script>
$(document).ready(function () {
//Examples of how to assign the Colorbox event to elements
$(".iframe").colorbox({ iframe: true, width: "80%", height: "40%" });
$(".callbacks").colorbox({
onOpen: function () { alert('onOpen: colorbox is about to open'); },
onLoad: function () { alert('onLoad: colorbox has started to load the targeted content'); },
onComplete: function () { alert('onComplete: colorbox has displayed the loaded content'); },
onCleanup: function () { alert('onCleanup: colorbox has begun the close process'); },
onClosed: function () { alert('onClosed: colorbox has completely closed'); }
});
//Example of preserving a JavaScript event for inline calls.
$("#click").click(function () {
$('#click').css({ "background-color": "#f00", "color": "#fff", "cursor": "inherit" }).text("Open this window again and this message will still be here.");
return false;
});
});
</script>
In the page, I use this to open up the window<li><a href="mypage.aspx?CMCID=new" class="iframe">Contact</a></li>
Is there a way to do the same thing from javascript? What I am doing is using GridView in a .net and use LinkButton to send the ID back to code behind, then send back that ID back to .net Javascript to use Colorbox
<asp:LinkButton ID="LinkButton4" CommandArgument='<%# Eval("ID") %>' CommandName="Link" runat="server" Visible="true" HeaderStyle-Width="10%"><%# Eval("ContactName")%></asp:LinkButton>
Sorry, I am sure there are better ways. But this is the only way I know..thanks
ASKER
I think this is too advanced. (sorry)
I am hoping I could explain clearer.
The colorbox is to open a window inside a page. I am not sure how to call the colorbox function from javascript. (I am sorry if you have explained it) thanks
I am hoping I could explain clearer.
The colorbox is to open a window inside a page. I am not sure how to call the colorbox function from javascript. (I am sorry if you have explained it) thanks
did you try :
$(".iframe").click();
ASKER
I guess my question is how to make this to work. Calling jquery while opening up a page inside a page. thanks
location.href = "ContactManagementContact. aspx?CMCID =new" + "class=iframe";
location.href = "ContactManagementContact.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you very much...
ASKER
one last question, where can I set what page it opens? thank you
you may store that info in a data-XYZ attribute for example :
No more inline OnClientClick attribute
No more inline OnClientClick attribute
<script>
jQuery(function($) {
$(".colorbox-opener").click(function(evt) {
evt.preventDefault();
var page = $(this).data("page");
$('.iframe').attr("href", "mypage.aspx?CMCID=new&page=" + page); // here we update the href, not sure if that work... if not, open a new question please
$('.iframe').click();
});
});
</script>
</head>
<asp:LinkButton CssClass="colorbox-opener" data-page='<%# Eval("ContactName")%>' ID="LinkButton4" CommandArgument='<%# Eval("ID") %>' CommandName="Link" runat="server" Visible="true" HeaderStyle-Width="10%"><%# Eval("ContactName")%></asp:LinkButton>
ASKER
okay, thank you very much.
Create a static web method:
Open in new window
Then in a Javascript function, call the web method:
Open in new window
You can use the success: function to process the return and do whatever it is that happens next.