Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I get asp.net aspx page name from javascript?

Trying to get the aspx name from the current page from javascript?

like image 987
user603007 Avatar asked Jan 18 '23 10:01

user603007


2 Answers

Try this

<script language="javascript">  
        var url = window.location.pathname;  
        var myPageName = url.substring(url.lastIndexOf('/') + 1);      
        alert(myPageName);  
</script>  
like image 130
Tariqulazam Avatar answered Jan 27 '23 19:01

Tariqulazam


As an alternative -

var page = '<%=Path.GetFileName(Request.Path)%>'

Do you want to parse the current window, or rely on asp.net? Both work - it's up to you.

like image 43
Adam Tuliper Avatar answered Jan 27 '23 18:01

Adam Tuliper