Bootstrap modal with remote ASP.NET webforms url - asp.net

I'm building up a website in ASP.NET Webforms and Bootstrap.
I have created a webform with masterpage page which contains a link to open up the Bootstrap modal with contents of another page ( Test.aspx ).
<a href="Test.aspx" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#modalTime">
Launch demo modal
</a>
The Test.aspx page is also a webform with masterpage file because without the modal it has to have the same content ( header, footer, ... ) as all other pages when you surf to it.
But in the modal it also adds the content of the masterpage ( header, footer, ... ). Which is normal, I understand this.
But is their another way or component or something else that when you surf to Test.aspx you see all the contents and in the modal you only see some content? Displaying only content within a Contentplaceholder?
Or is this only possible in MVC because of the use of views? Maybe there is something simular in webforms?

This can be solved in multiple ways. The two ways I would suggest is the following:
1) Move most logic out in an ASCX control. Then you can keep test.aspx, but also have a new one called Modaltest.aspx, and you can use that one for the modal window.
2) On the masterpage, you have a property called "IsAjax", that looks at the header. If the header is an AJAX call, you simply remove all its surroundings. We've done that at one of our legacy Web Forms project at work, which works OK.

Related

inject a view in another view that has been already loaded in asp.net mvc 6?

someone need help here :( !!
I have a bloc of authantification html code and a btn for login and another for register. These two buttons are in all pages but I don't want my authantification code to be loaded in every pages (Render***() in _Layout.cshtml). I want to inject this bloc code in the page on login or register btn clicked.
exp: client want to register after visited pageTwo (the authantification html code is not loaded yet), and then he press the register btn => at this time the authantification html code is loaded (injected) without loading the entire pageTwo.
My authantification html is a modal, just to give you an idea:
<div class="modal" style="z-index:10000"> ... </div>
My queation: how can I inject a view(html) in the view that has been already loaded by pressing on a button ?
Thanks for helping if it's not clear let me know, and sorry for the bad english :(
UPDATE
Is it possible without server side manipulation ?
If you don't want server-side code, you need client-side code.
When button is clicked, use javascript to load html (with markup of login form only) from server, insert it into your current page (into model dialog for example) and then show that form/dialog.
jQuery will help you with html manipulation and when communicating with server, later you can switch to vanilla.js for less javascript libs in dependencies.

Render An aspx File (Menu Bar) in Razor View Layout Page

I have been looking around looking for a solution for this issue but have yet to arrive to a solution that works. I was using this as a reference but couldn't get anything to work:What is the right way to '#include file' in MVC?
I have an MVC 4 project that uses a Razor for the views and I want to add an aspx page that contains a menu bar that I would to add to the _LayoutPage.cshtml. As of right now I have recreated the menu so it looks the same in my razor view but the issue is that when a change needs to be made to the menu.aspx page I have to make the same changes in my razor view.
So my goal is to just render this menu in my layout.cshtml page.
This is what i have right now but it does not work. Is there anyway to do this?
<div id="page-header">
#Html.RenderPartial("P:/menu/menu.aspx")
</div>
Place your .aspx file in Views foulder and then:
#Html.Partial("~/Views/WebForms/menu/menu.aspx")
Also, could be that it is not working becouse RenderPartial works other way, try:
#{ Html.RenderPartial("P:/menu/menu.aspx"); }

In aspx with mvc 4, how to modify layout pages slightly on opening of a new page

When an htmlActionLink is clicked, a new page (say About) is opened with layout and the main body is rendered from the corresponding view. I want to change the style of the about link to show that this link is active. I tried a lot using jquery. It changes momentarily, but it comes back to its original style. I have not tried it through controller. I've used jquery in the layout.cshtml and about.cshtml page.
Look in to MvcSiteMap. You can use the MVC helpers to create a navigation menu that changes as you visit pages. Also, keeping it server side over using jQuery is going to be the best bet.

Navigating away from page referenced using iframe

What I have at the moment is a page which I am using as a sirt of site master for my html pages. The way I am doing this is by referencing the master page using this line of code:
<iframe scrolling="no" style="width:100%;" frameBorder="0" src="WebForm1.aspx"></iframe>
Now that works fine, I can create a new page and reference that, and then the content from that page will appear on any page referencing it.
But I have a problem, what I want Is if you click the navigation button that is in header of a page that is referencing this site master; it navigates away but only the iframe will hold the webpage, and the main content will still be the same.
For example:
In the master page I am referencing using the Iframe, I have some code that when you click on a button it navigates away, ok. But if I go into a page that is referencing the master and click the button, the new web page will only open in the iframe section at the top of the page.
Sorry for this complicated question, if anyone understands it, then any advice would be helpful!
The page that is referencing the master:
http://codepad.org/IyrDxAf9
The master page itself:
http://codepad.org/XMu67H1M
PS...I am coding this in asp.net using html
The aim of all this is to create a master page for html, but I am not having much luck with it
You can set the following in your webform1.aspx page:
<base target="_parent" />
This will target all the links on that page to the 'parent' window. You can also do this with individual links.
Seeing as you are using .aspx pages here, is there a reason why you are not using the built in master page functionality?

ASP.NET Forms and jQuery Mobile Contradictory Logic

I'm running into what looks like a contradiction between jQuery Mobile and ASP.NET Forms. I have two pages that I'm transitioning between using jQuery Mobile page transitions. The basic structure looks something like this:
<html>
<body>
<div id="page1" data-role="page">
<form id="aspNetForm" runat="server">
Page 1
Page 2
<!-- Some more ASP.NET controls that require the aspNetForm -->
</form>
</div>
<div id="page2" data-role="page">
Page 2
Page 1
</div>
</body>
</html>
Notice that the form tag is only present in the first page. That's because ASP.NET only allows one form per page. When I try and move the form tag outside of the page divs jQuery Mobile starts acting strange (specifically the page transitions start looking strange). This becomes a problem when I want to use any sort of ASP.NET web controls that deliver input inside the second page.
Basically these rules exist that essentially lead to a contradiction:
ASP.NET:
1) All web controls that deliver an input must be within an ASP.NET form tag
2) Only one ASP.NET form tag can be visible (as in visible=True, not display: block) per page request
jQuery Mobile:
1) All content, including forms, must be within a page div
Can anyone think of a way to get around this? I guess I could restrict page2 to only use traditional HTML and not web controls but that doesn't seem like the most elegant solution. Any ideas? Has anyone else run into this?
Well. In my opinion, the simple solution would be to give each page its own .aspx-file. That would work just fine.
If your site is very big, it would also improve performance.

Resources