Web Form Cutting Off After Special Character - c#

I have a simple web form where a person can enter into a textbox what kind of project they want. For example, they may type in: Sales & Projection report needs to be fixed.
They then click a submit button and it gets sent off to a third party website that keeps track of our projects.
The problem is, in the example given above, everything gets cut off after the '&' symbol.
it gets sent like this:
String request = "fct=createorcopyproject&guid=" + guid + "&projectname=" + TxtProjectName.Text + "&projectdesc=" + TxtDescription.Text +
"&nexttasknumber=1&budgethours=0&budgetcost=0&estimatedstartdate=" + year + "-" + month + "-" + day + "&estimatedenddate=" + year + "-" + month + "-" + day + "&estimatedhours=0&estimatedexpenses=0&projectpriorityid=" + priorityIndex + "&projectstatusid=NULL&projecttemplate=0&contactname=" + user +
"&defaultestimatedtime=0&defaulttaskstartdate=1&defaulttaskenddate=1&defaulttaskactualdates=2&clientid=" + areaIndex + "&createdefaults=True&languagedefaults=EN&projecttemplateid=0000003&keeptemplatelink=false&copyprojectassignments=True&copyprojectdocuments=True&copyforumtopics=False&copytasks=False&adjusttaskdates=False&copytaskdocuments=False&copytaskassignments=False&markproject=False&format=ds";
Where TxtDescription.Text is where we are getting the cutoff.
Is this something on their end or am I missing something?

Use HttpUtility.UrlEncode method to encode the values you send in an URL (assuming this is an URL)

Related

c# textbox-as-filename problems

I have been trying to make a program and it saves mechanics invoices. So I have got this far;
oWord.Application.ActiveDocument.SaveAs2("C:/BMW/Invoices/" + Regbox.Text + "/thing.doc");
which saves the word doc in a folder that is specified by the registration of the bike - this works fine. but what I really want is the date to be used as a filename...I couldn't figure that out, so I made a date label and plan on using the text from it as the filename instead (I know, its a long way round...but it works). Anyways, I have tried;
oWord.Application.ActiveDocument.SaveAs2("C:/BMW/Invoices/" + Regbox.Text + "/" + label19.Text + ".doc");
this was an "invalid filename"
oWord.Application.ActiveDocument.SaveAs2("C:/BMW/Invoices/" + Regbox.Text + "/label19.Text.doc");
this saved it as "label19.Text.doc"
oWord.Application.ActiveDocument.SaveAs2("C:/BMW/Invoices/" + Regbox.Text + "/" + label19.Text, ".doc");
This threw the error "(DISP_E_TYPEMISMATCH)"
All I need to do is get label19 text to work as a filename with a .doc extension...or another way of getting the date as a filename
If you need to use current date as file name then you can use:
oWord.Application.ActiveDocument.SaveAs2("C:/BMW/Invoices/" + Regbox.Text + "/" + DateTime.Now.ToString("MM-dd-yyyy") + ".doc")
Generate the file name in an string variable:
string filename = "C:/BMW/Invoices/" + Regbox.Text + "/" + DateTime.Now.ToString("MM-dd-yy");
and then pass it to SaveAs2 method:
oWord.Application.ActiveDocument.SaveAs2(filename, ".doc");

How to check if a date falls between two other dates in XPath

I'm trying to pull event logs from a windows PC given certain information. This block of code is working fine but only pulls logs from the current day. I'd like to only pull logs that where created between dates that are specified earlier, "toDate" and "fromDate". This is my first time using xpath and I can't seem to find anything online that deals with something like this.
string queryString =
"<QueryList>" +
" <Query Id=\"0\" Path=\"Application\">" +
" <Select Path=\"Application\">" +
" *[System[(Level=3) and " +
" TimeCreated[timediff(#SystemTime) <= 86400000]]]" +
" </Select>" +
" </Query>" +
"</QueryList>";

Parse C# unformated strings in source code then convert to string format

There thousands of calls to log4net in the application which were done with the style of string concatenation instead of using string format like "{0} is greater then {1}".
So we wrote a program that will parse all the .cs files using Regex to find the log4net logging statements. It extracts the code between the parentheses () and then calls a method to reformat it and return the results. Then it rewrites the source code file.
This question relates to the method that reformats the log statement.
It receives an argument of string and returns string.
Here's a sample of the log statements:
"Column " + column + " Seq Cnt: " + sequentialCount + ": Seq Avg: " + (sequentialTotal / sequentialCount)
"Opening file for writing copy protection failed. Retrying.", ex
"for assert " + value.ToString("X")
"ExpirationTime()"
"count = " + count + ", round << " + count + " = " + (round << count)
"Total Diff Bytes = " + (7*count)
(series.Count - i - 1) + " " + series.Time[i] + " O,H,L,C:" + series.Open[i].ToDouble() + "," +
series.High[i].ToDouble() + "," +
series.Low[i].ToDouble() + "," +
series.Close[i].ToDouble()
"Recovered orders from snapshot: \n" + OrderStore.OrdersToString()
Essentially, it seems that the plan should be to use Regex.Replace() with a MatchEvaluator.
What is the correct Regex expression for the Regex.Replace?
These seem to be the requirements:
Essentially find each interruption in the string "\s*+\s*(.*)\s+" (over simplified).
Replace each match with a token of the form {0} in the string and then put the specified value as an argument to the method.
Debug methods of the form log.Debug("message",ex) which have a reference to an exception must be identified and skipped.
Of course, the code will switch the calls to DebugFormat() InfoFormat() and so on.
The problem with the above Regex is that it matches this as the first match:
" + column + " Seq Cnt: " + sequentialCount + "
instead of:
" + column + "
I can't simply use ([^"]) instead of (.) or ([^+]*) since some of the values have additional plus or use quotes as arguments to methods.
So it needs some way to say match all characters except if the match the pattern \s+\s" which means plus sign followed by a quote separated by optional white space.
You can make the quantifier lazy. For example:
"\s*\+\s*(\S.*?)\s*\+\s*"

adding space and new line in html editor asp.net ajax

I want to insert blank characters in a string move to next line and align right in Html editor ajax control and it should be hardcoded in my below code .
My code is
Editor1.Content = "No. J/" + DropDownList3.SelectedItem + "-" + TextBox1.Text + "-" + tyear + "/" + " " + "/" + year + DateTime.Now.Day+"/"+DateTime.Now.Month+"/"+DateTime.Now.Year;
What i want is
i want 5 blank spaces after
....+ tyear + "/" + "....
Move to next/new line after
....." + "/" + year +....
Apply Align left to this entire
content
To add blank spaces to the keyword. Normal blank spaces will be ignored as whitespace by the HTML parser.

MS Access statement for selecting data within selected date

I need a statement to select data from an MS Access database table.
WITHIN selected dates
I have two textboxes in my GUI called StartDate and EndDate
I want to select data within those 2 dates.
I have tried 2 methods.
The first is
" DAY(V.RegDate) between " + Start.ToString("dd")
+ " and " + End.ToString("dd");
" and MONTH(V.RegDate) between " + Start.ToString("MM") + " and "
+ End.ToString("MM");
" and YEAR(V.RegDate) between " + Start.ToString("yyyy") + " and "
+ End.ToString("yyyy");
V.RegDate is the date column from the database.
But it returns me no data when I select 01/08/2010 and 01/09/2010 while there is some data at 25/08/2010.
I think that is because I chose the date separately and since the 2 dates are the same,
returns me nothing
I have tried another way...
" V.RegDate between #" + Start.ToString("dd/MM/yyyy") + "# and #" _
+ End.ToString("dd/MM/yyyy") + "#";
This also return me nothing
Any Ideas????
This pattern works for me:
SELECT sometable.somedate
FROM sometable
WHERE (((sometable.somedate) Between #2/1/2010# And #4/1/2010#));
(in this case it's MDY, I normally prefer ISO-ish style - YYYY/MM/DD because there is no way that Access can screw that up)
Maybe you've got your date set using the American default - MDY instead of the British(?) standard DMY.

Categories