Me.("data-target", "#" & pnlModal.ClientID)Ĭredit: This post builds upon KHComputersâ excellent contribution about Bootstrap Modal Dialogs in ASP. Protected Sub Page_Load(sender As Object, e As EventArgs) Since data-target isnât a standard, supported HTML attribute, you can use the Attributes.Add method to set it via the Page_Load event of your code-behind as follows: To solve this, you just need to set the data-target to pnlModalâs clientID (the rendered name). If you're using the data-api, you may alternatively use the href attribute to specify the remote source. According to Bootstrap's documentation: If a remote URL is provided, content will be loaded one time via jQuery's load method and injected into the. The problem is that in an application with master pages, the actual rendered name of the pnlModal div will likely become something like âctl00_ContentPlaceHolder1_pnlModalâ and Bootstrap wonât be able to associate it with the necessary JavaScript to show the dialog so the button does nothing. Quickly get a project started with any of our examples ranging from using parts of the framework to custom components and layouts. The way you're trying to get modal's content from another page is incorrect. Why? The answer comes down to the âdata-targetâ attribute of the invoking button, which is meant to tell Bootstrap the panel to activate: But try the same thing in an ASP.Net app with a master page and nothing happens. Pushing the button shows the dialog, and everythingâs ducky. Most examples for using Bootstrapâs very robust dialog support go something like this: No error messages, just nothing.Īny ideas/comments would be greatly appreciated.įunction on master page function ShowAlert(heading,message) ') ", alertHeading, alertMessage) ĬlientScript.RegisterStartupScript(this.This is a short blog about solving a nasty problem with using Bootstrapâs Modal Dialogs with ASP.NET and Master Pages. In my project, the pop-up opens properly, but no data is loaded inside the modal. ![]() A more advanced and tricky suggestion: Put the Modal code at the end. A good practice to improve the page's loading speed is putting the Modal code at the end of the page, besides this helps you avoid any conflict with other UpdatePanels or elements. Define it as an control and make sure that it includes a Button control. First, we set the Modal's Title and Body, then display it, and finally update the UpdatePanel.![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |