UrlFormat, ParamFormat and constants

3 views
Skip to first unread message

teuc...@gmx.at

unread,
Dec 9, 2006, 4:00:29 PM12/9/06
to PageMethods
Using constants as arguments for ParamFormatAttribute and may be also
UrlFormatAttribute (not tested) does not work:

Have a look at this VB.NET code:

<PageMethod(True)> _
<UrlFormat("~/{year}/Formulare.aspx")> _
Protected Sub ShowForms(<ParamFormat(Formats.Year4)> ByVal year As
Integer)
'...
End Sub

Formats is a Module/static class and Year4 a string constant: "0000".
The rendered URL looks like this:

http://localhost:2000/WebSite/Formats2006Year4/Formulare.aspx

instead of

http://localhost:2000/WebSite/2006/Formulare.aspx

Do you have any ideas or solutions for this?

Thanks.

Marco

Fabrice Marguerie

unread,
Dec 27, 2006, 9:15:47 AM12/27/06
to PageMethods
Hello Marco,

I've been able to reproduce the problem and I understand where the
problem comes from. Unfortunately, there is no easy way the PageMethods
add-in can get the value of constants. PageMethods uses Visual Studio's
code model, which only provides "Formats.Year4" as the argument for the
ParamFormat attribute. I haven't found a way to evaluate
"Formats.Year4" to get "0000".
Maybe this is something you'll be able to do once we use a different
parser, but for the moment, you can't use constants as arguments to
PageMethods' attributes.

Fabrice

Marco v. Frieling

unread,
Dec 30, 2006, 12:18:14 PM12/30/06
to PageMethods
Hello Fabrice,

thanks for your answer and explanations.

Marco

Reply all
Reply to author
Forward
0 new messages