|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Combining 2 variablesBrand new to .aspx, and just modifying code.
I have this: writer.WriteLine("DTSTART:" & beginDate.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z") ) I am grabbing the date and time from two fields and just need to combine them into one string for the above to work and I don't know how in .aspx. Here are my fields I am trying to combine, it also look slike there shouldn't be a space between them, looking at the above lines: Dim beginDate as Date = Request.Form.GetValues("date")(0) Dim beginTime as StartTime = Request.Form.GetValues("StartTime")(0) So in other words, I need to append StartTime to beginTime so the whole value will show up. This is for making an Outlook Celendar appointment, BTW. FYI. You should be using ASP.NET Server controls and thus your ASPX
markup should look something like this. Please note that naming convention can vary i just prefer Hungarian notation because it makes long term maintainability alot easier. <asp:TextBox Id="txtBeginDate" runat="Server" /> <asp:TextBox Id="txtBeginTime" runat="Server" /> Your codebehind should look something like this. String strBeginDate = txtBeginDate.Text.Trim() + " " + txtBeginTime.Text.Trim(); then you could say DateTime FullBeginDate = DateTime DateTime.Parse(FullBeginDate); or use a ParseExact variant, depending upon your needs. Hope this helps to clear some stuff up and open some other avenues. Still not quite getting it sorry.
I have these and it is pulling in the data correctly: Dim beginDate as Date = Request.Form.GetValues("date")(0) Dim beginTime as Date = Request.Form.GetValues("sTime")(0) Now I just need to combine those two values into one varible, I didn't quite understand that code. Is there a way to just do something like beginDate = beginDate + beginTime or beginDate = beginDate & beginTime I also looked into the .append but I am guessing since I am dealing with a date vs. a string this won't work??? This code is doing some conversion for me, but this is where I already need the combined data: writer.WriteLine("DTSTART:" & beginDate.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z") ) I hate to be a pain, but could you try (using my variable) shoot some more code at me I can play with?? Thanks a million!!! Show quoteHide quote "recoil@community.nospam" <marc.deri***@gmail.com> wrote in message news:1111423627.965187.75350@l41g2000cwc.googlegroups.com... > FYI. You should be using ASP.NET Server controls and thus your ASPX > markup should look something like this. Please note that naming > convention can vary i just prefer Hungarian notation because it makes > long term maintainability alot easier. > <asp:TextBox Id="txtBeginDate" runat="Server" /> > <asp:TextBox Id="txtBeginTime" runat="Server" /> > > Your codebehind should look something like this. > String strBeginDate = txtBeginDate.Text.Trim() + " " + > txtBeginTime.Text.Trim(); > then you could say > DateTime FullBeginDate = DateTime DateTime.Parse(FullBeginDate); or > use a ParseExact variant, depending upon your needs. > > Hope this helps to clear some stuff up and open some other avenues. > That is not really the standard method of doing what you are attempting
to accomplish. Your method is extremely backwards and requires going through a bunch of unnecessary loops Try this but once again this is NOT the preferred method of doing this. You could actually combine this in shorter code but since it seems like you are very new I am going to spell it out so that you can see all of the steps being taken out. Before you can lean to walk you must first learn to crawl. Dim strBeginDate as String = Request.Form.GetValues("date")(0) Dim strBeginTime as String = Request.Form.GetValues("sTime")(0) Dim strTotalBegin as String = strBeginDate + strBeginTime Dim beginDateas Date = DateTime.Parse(strTotalBegin) writer.WriteLine("DTSTART:" & beginDate.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z") )
Other interesting topics
Handle HttpRequestValidationException gracefully
Making objects move along with resizing browser page ? FCKeditor implementation in ASP.NET Nesting Literal Control in anchor tags Problems with Update and MySqlDataAdapter Problem with databinding expression Arrays and DataReader Q: DataGrid during edit IE messing up with font of web pages. DirectorySearcher - whats wrong with this?! |
|||||||||||||||||||||||