Home > ASP.NET > Open FancyBox from Code behind on button click

Open FancyBox from Code behind on button click


Add link like following which redirect to popup page that you want to open on button click using fancybox

[1] <a href=”../Scripts/ValidationMessage.aspx” class=”fancybox fancybox.iframe” id=”hiddenlink_confirm” />

Add following js function on head of page along with fancybox script

[2] <script type=”text/javascript”>

function OpenValidationMessagePopup() {
var alink = document.getElementById(“hiddenlink_confirm”);
alink.click();
}

[3] Write following code on button click event

Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click

Dim sb As New StringBuilder()

sb.AppendFormat(“OpenValidationMessagePopup();”)
ScriptManager.RegisterStartupScript(Me.Page, Me.[GetType](), “OpenValidationMessagePopup” + DateAndTime.Now, sb.ToString(), True)

End Sub

Will add some more information to the above steps, hope this help !

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: