hi iam getting date as like '1/01/2010' from a dateofarrival(name of text box id) .......
i want to replace the ' from '1/01'2010'.,
iam interested to show as like 1/01/2010.........
plsa help me,,,,,,,,,,

here iam using asp.net with vb.net ........
here my coding is.....

Response.Redirect("check availability.aspx?ardate='" & dateofarrival.Text & "' ")


Dim ardate
ardate = Request.QueryString("ardate")
arrivaldate.Text = ardate

pls help me urgent...........

Dani AI

Generated

— the problem is the single quotes that were added around the date when the URL was built. That causes the query string value to be "'1/01/2010'" instead of "1/01/2010". was on the right track about not wrapping the value and encoding it; if you cannot change the sender, handle it on the receiver by decoding, trimming stray quotes, validating the text as a date, and then formatting it for display.

Here is a receiver-side VB.NET pattern that is more robust than assigning the raw query value directly:

' clean/parse a date from the query string
Dim raw As String = Page.Request.QueryString("ardate")
If String.IsNullOrWhiteSpace(raw) Then
  arrivaldate.Text = "Invalid date"
Else
  raw = raw.Trim()
  If raw.StartsWith("'") AndAlso raw.EndsWith("'") AndAlso raw.Length > 1 Then
    raw = raw.Substring(1, raw.Length - 2)
  End If
  raw = System.Web.HttpUtility.UrlDecode(raw)

  Dim dt As DateTime
  Dim formats As String() = {"d/M/yyyy","dd/MM/yyyy","M/d/yyyy","MM/dd/yyyy","yyyy-MM-dd"}
  If DateTime.TryParseExact(raw, formats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, dt) Then
    arrivaldate.Text = dt.ToString("dd/MM/yyyy")
  ElseIf DateTime.TryParse(raw, System.Globalization.CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None, dt) Then
    arrivaldate.Text = dt.ToString("dd/MM/yyyy")
  Else
    arrivaldate.Text = raw ' or show an error
  End If
End If

Notes: prefer sending dates in an unambiguous form (ISO 8601, e.g. yyyy-MM-dd) so parsing is deterministic; URL-encode values when building the query; avoid spaces in page names; validate all input server-side. For parsing details see DateTime.TryParseExact. This builds on 's and 's comments while adding safe parsing and formatting.

Recommended Answers

All 2 Replies

Friend kanuri1,

"urgent..." sounds unfriendly. Isn't it? Please help us to help you.

Please do not post threads with generic subjects such as "URGENT!!" or "HELP ME" or "PROBLEM". Instead, clearly state a phrase describing the problem as the thread's title.

I love learning and teaching languages, so feel free to talk to me in any language any time here.

Response.Redirect("check availability.aspx?ardate='" & dateofarrival.Text & "' ")


Dim ardate
ardate = Request.QueryString("ardate")
arrivaldate.Text = ardate

It is unnecessary to append single quotes around the value you are inserting into a querystring. However, you may want to include a call to Server.UrlEncode for the value.

Response.Redirect("check availability.aspx?ardate=" & Server.UrlEncode(dateofarrival.Text))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.