• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

parsing <%= Now %> as default parameter in querystring

The code attached works fine, all I want to do is use today's date instead of 27/10/2011 as the default value.  I have tried using <%= Now %> but keep getting errors,

i have tried;

Request.QueryString("calendarVal"),"<%= Now %>"
which doesn't work because in the quotes is a string value, also tried;

Request.QueryString("calendarVal"), & <%= Now %> to no avail, any ideas?




<Parameter  Name="@calendarVal"  Value='<%# IIf((Request.QueryString("calendarVal") <> Nothing), Request.QueryString("calendarVal"),"27/10/2011") %>'  Type="Date"   Direction="Input" />

Open in new window

0
Enduro1983
Asked:
Enduro1983
  • 4
  • 4
1 Solution
 
Snarf0001Commented:
What's the error?  If it's the quote error, try formatting Now in the string:



Request.QueryString("calendarVal"),"<%= Now.ToString("MM/dd/yyyy") %>"
0
 
Enduro1983Author Commented:
Hi Snarf,

if i change it to
Request.QueryString("calendarVal"),<%= Now.ToString("MM/dd/yyyy") %>
i get an BC30201: Expression expected.

if i change it to (what you put)
Request.QueryString("calendarVal"),"<%= Now.ToString("MM/dd/yyyy") %>"
I get an BC32017: Comma, ')', or a valid expression continuation expected.
<Parameter  Name="@calendarVal"  Value='<%# IIf((Request.QueryString("calendarVal") <> Nothing), Request.QueryString("calendarVal"),<%= Now.ToString("MM/dd/yyyy") %>) %>'  Type="Date"   Direction="Input" />

Open in new window

0
 
Snarf0001Commented:
Sorry, gave you an extra <% in there:
<Parameter  Name="@calendarVal"  Value='<%# IIf((Request.QueryString("calendarVal") <> Nothing), Request.QueryString("calendarVal"), Now.ToString("MM/dd/yyyy") %>'  Type="Date"   Direction="Input" />

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Enduro1983Author Commented:
different message!!

BC30057: Too many arguments to 'Public Function IIf(Expression As Boolean, TruePart As Object, FalsePart As Object) As Object'.
0
 
Snarf0001Commented:
#*@('n syntax, forgot the end ")"
<Parameter  Name="@calendarVal"  Value='<%# IIf((Request.QueryString("calendarVal") <> Nothing), Request.QueryString("calendarVal"), Now.ToString("MM/dd/yyyy") %>'  Type="Date"   Direction="Input" />

Open in new window

0
 
Snarf0001Commented:
again, forgot the same thing:

not my day...
<Parameter  Name="@calendarVal"  Value='<%# IIf((Request.QueryString("calendarVal") <> Nothing), Request.QueryString("calendarVal"), Now.ToString("MM/dd/yyyy")) %>'  Type="Date"   Direction="Input" />

Open in new window

0
 
Enduro1983Author Commented:
Hi Snarf,

another error, unrelated I think, is it to do with the string not being a date i wonder???

System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at System.DateTime.Parse(String s)
at DreamweaverCtrls.DataSet.ConvertParameterValue(String strValue, Enum theType)
at DreamweaverCtrls.DataSet.AddParameters(IDbCommand myCommand)
at DreamweaverCtrls.DataSet.DoInit()
0
 
Enduro1983Author Commented:
Hi Snarf,

I changed it to the code below, it is not throwing an error, I have not fully checked whether it is doing anything apart from not throwing an error!! Got to do some more bits to the actual query, will post them q's in another post.  Cheers for your time!
<Parameter  Name="@calendarVal"  Value='<%# IIf((Request.QueryString("calendarVal") <> Nothing), Request.QueryString("calendarVal"), Now) %>'  Type="Date"   Direction="Input" />

Open in new window

0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now