U mean to say outside $(document).ready(function () { . I tried that also but not working
Is there anyway that you can explain clearly what you are trying to do and post all the relevant source code? Phrases like "not working" is not specific enough to guess or reproduce your exact scenario.
Member
504 Points
1776 Posts
Url with Resolve Url
Jul 29, 2018 10:09 AM|JagjitSingh|LINK
H
How to replace below line
url: "/WebService.asmx/GetData"
with ResolveUrl
Thanks
All-Star
52291 Points
23326 Posts
Re: Url with Resolve Url
Jul 29, 2018 12:32 PM|mgebhard|LINK
Use code blocks.
Keep in mind the snippet of code above must exist in an ASPX page and not a JS file. JS files are static and not part of the page life cycle.
All-Star
54508 Points
14111 Posts
Re: Url with Resolve Url
Jul 29, 2018 12:48 PM|mudassarkhan|LINK
Use ~ sign so that ASP.Net will get the correct path with ResolveUrl
Blog: ASPSnippets | Forum: ASPForums | Company: Excelasoft
All-Star
54508 Points
14111 Posts
Re: Url with Resolve Url
Jul 29, 2018 12:50 PM|mudassarkhan|LINK
And if you want to use in JS also then do this way
in ASPX create a variable
And then in JS use
Blog: ASPSnippets | Forum: ASPForums | Company: Excelasoft
Member
504 Points
1776 Posts
Re: Url with Resolve Url
Jul 29, 2018 01:19 PM|JagjitSingh|LINK
Hi
I have defined like this but it is saying GetDataUrl is not defined
$(document).ready(function () {
var GetDataUrl = '<%=ResolveUrl("~/WebService.asmx/GetData") %>';
});
function loadData()
{
$.ajax({
type: "POST",
dataType: "json",
url: GetDataUrl,
success: function (data) {
var dt = $('#studentTable').DataTable({
columnDefs: [{ orderable: false, targets: [2] }],
//columnDefs: [{ visible: false, targets: [0] }],
emptyrecords: 'No records to display',
data: data,
columns: [
{ 'data': 'No' },
{ 'data': 'Description' },
{
"mRender": function (data, type, row) {
debugger
return '<a class="btn btn-warning" onClick="getbyID(' + row.Id + ')" href="#">Edit</a>';
}
}]
});
}
});
}
Thanks
All-Star
54508 Points
14111 Posts
Re: Url with Resolve Url
Jul 29, 2018 01:38 PM|mudassarkhan|LINK
Just use
var GetDataUrl = '<%=ResolveUrl("~/WebService.asmx/GetData") %>';
Blog: ASPSnippets | Forum: ASPForums | Company: Excelasoft
Member
504 Points
1776 Posts
Re: Url with Resolve Url
Jul 29, 2018 02:12 PM|JagjitSingh|LINK
Hi
U mean to say outside $(document).ready(function () { . I tried that also but not working
Thanks
All-Star
52291 Points
23326 Posts
Re: Url with Resolve Url
Jul 29, 2018 02:42 PM|mgebhard|LINK
Is there anyway that you can explain clearly what you are trying to do and post all the relevant source code? Phrases like "not working" is not specific enough to guess or reproduce your exact scenario.
All-Star
54508 Points
14111 Posts
Re: Url with Resolve Url
Jul 29, 2018 02:52 PM|mudassarkhan|LINK
YES.
Please share full code
Blog: ASPSnippets | Forum: ASPForums | Company: Excelasoft
Member
504 Points
1776 Posts
Re: Url with Resolve Url
Jul 29, 2018 03:01 PM|JagjitSingh|LINK
Hi
var GetDataUrl = '<%=ResolveUrl("~/WebService.asmx/GetAllCategories") %>';
Thanks
All-Star
54508 Points
14111 Posts
Re: Url with Resolve Url
Jul 29, 2018 03:30 PM|mudassarkhan|LINK
Put
var GetDataUrl = '<%=ResolveUrl("~/WebService.asmx/GetAllCategories") %>';
above
Blog: ASPSnippets | Forum: ASPForums | Company: Excelasoft