I have some code which gets the DrawingId from an url like the one below:
/Queue/Queue.aspx?Mode=Autosearch&DrawingID=188320"
My issue is after running another part of the program, that url becomes this:
/Queue/Queue.aspx?Mode=Autosearch&DrawingID=188320?DrawingRequestId=376333&doQuerySearch=true&start=&end=&Ind=&Model=&status=Open&manager=&source=&assignee=&title=&features=&parts=&pas=&customer=&number=&project=&startIndex=1&endIndex=10&pageSize=10&total=193&date=Extended&qsEnd=
Is there a good way remove everything after 188320? Also is there a good way to extract the DrawingRequestId of 376333?
Here is the code for DrawingID:
public string DrawingId
{
get
{
if (Request.QueryString["DrawingID"] != "" && Request.QueryString["DrawingID"] != null)
{
return Request.QueryString["DrawingID"];
}
return null;
}
}
This part won't run because the DrawingId becomes incorrect:
List<string> featureCodes = drawingBusiness.GetFeatureCodesByDrawingId(long.Parse(DrawingId));
This code doesn't work because instead of DrawingId just being 188320,
it becomes 188320?DrawingRequestId=376333
Here is the javascript where I assume the problem is starting:
function CloseAndRefresh() {
var parentUrl = window.top.location.href;
if (parentUrl.indexOf("Queue/Queue.aspx") != -1) {
if (window.location.search === "") {
window.location.href = window.top.location
}
else {
window.top.location.href = window.top.location + window.location.search;
}
}
else {
if (window.location.search === "") {
window.location.href = window.top.location
}
else {
window.top.location.href = window.top.location + window.location.search;
}
}
}
To remove all the code appended to your url you can do something like:
var longURL = "/Queue/Queue.aspx?Mode=Autosearch&DrawingID=188320?DrawingRequestId=376333&doQuerySearch=true&start=&end=&Ind=&Model=&status=Open&manager=&source=&assignee=&title=&features=&parts=&pas=&customer=&number=&project=&startIndex=1&endIndex=10&pageSize=10&total=193&date=Extended&qsEnd=";
var shortURL = longURL.split('?').slice(0, -1).join('?');
console.log(shortURL) // "/Queue/Queue.aspx?Mode=Autosearch&DrawingID=188320"
To extract the DrawingRequestId
you can do something like:
var longURL = "/Queue/Queue.aspx?Mode=Autosearch&DrawingID=188320?DrawingRequestId=376333&doQuerySearch=true&start=&end=&Ind=&Model=&status=Open&manager=&source=&assignee=&title=&features=&parts=&pas=&customer=&number=&project=&startIndex=1&endIndex=10&pageSize=10&total=193&date=Extended&qsEnd=";
var drawingRequestId = parseInt(longURL.substr(longURL.indexOf('DrawingRequestId=')+17, 6));
console.log(drawingRequestId) // 376333