By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,905 Members | 2,075 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,905 IT Pros & Developers. It's quick & easy.

Is possible to use a method in a LinkButton declaration?

P: n/a
Hello,

If I code this:

[...]
<script language="c#" runat="server">
void Page_Load() {
Page.DataBind();
}

string giveMeAValue() {
string value = "here you have";
return value;
}
string giveMeAValue( aValue ) {
// some logic to determine the value
return value;
}

</script>

[...]

<form runat="server">
<asp:LinkButton CommandName="Sort" CommandArgument="login ASC" Text="<%#
giveMeAValue() %>" runat="server" />
</form>
[...]

It works fine, but if I try to pass a static parameter in the
giveMeAValue method like this:
[...]
<form runat="server">
<asp:LinkButton CommandName="Sort" CommandArgument="login ASC" Text="<%#
giveMeAValue( "aValue" ) %>" runat="server" />
</form>
[...]

It just says it's a malformed server tag.

Is there any way of passing a parameter in the TextField of a
LinkButton?

Thanks

Carlos CR
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Carlos, try:

<asp:LinkButton CommandName="Sort" CommandArgument="login ASC"
Text='<%# giveMeAValue( "aValue" ) %>' runat="server" />

Note that I changed the " around the value for Text to '

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
Nov 18 '05 #2

P: n/a
"Scott Mitchell [MVP]" <mi******@4guysfromrolla.com> wrote in
news:Qi*****************@newssvr27.news.prodigy.co m:
Carlos, try:

<asp:LinkButton CommandName="Sort" CommandArgument="login ASC"
Text='<%# giveMeAValue( "aValue" ) %>' runat="server" />

Note that I changed the " around the value for Text to '


Thank you very much. It works! :)

Regards

Carlos CR
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.