Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,
My requirement is , i have a razor view which contains textbox and a button, when i click on a button i want to open aspx. can somebody please help by posting a sample code on this. I want to pass textbox id and button id to the aspx page.

Thanks in advance!!
Posted
Comments
Jameel VM 24-Jul-14 7:38am    
did you try by using javascript by directly redirect to the url of the aspx page?
yadlaprasad 24-Jul-14 8:43am    
Hi Jameel,
Yes I tried,but no help..

<input type="button" value="MyButton" önclick="Newwindow(this)" data-myurl="@Url.Action("Index", "Home")"/>

<script type="text/javascript">

function Newwindow(e) {
var urlkp = $(this).attr("data-myurl");
alert(urlkp);
var popupWindow = window.open("Mypage.aspx", "XCV", 'scrollbars=1,height=650,width=1050');
}
</script>

above alert id displaying undefined. not sure what went wrong. Please help some alternative
ZurdoDev 24-Jul-14 13:32pm    
Debug this code and see what is happening.
Suvabrata Roy 24-Jul-14 9:51am    
Its this a View with aspx View engine or a aspx Page (web form)?

1 solution

It looks like your .aspx lives in the same directory as your Razor-driven application. The easiest way to skin this cat is to modify your App_Start/RouteConfig.cs file.

C#
public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.IgnoreRoute("{*allaspx}", new {allaspx=@".*\.aspx(/.*)?"}); // Add This

    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );
}


This should allow the page to load without the MVC application trying to parse it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900