开发者

passing a string parameter when calling a method in asp.net

开发者 https://www.devze.com 2022-12-22 03:05 出处:网络
I have this method in cs page: public String getToolTip(Object productId, Object imgBtnId) { return UtilsStatic.getWishListButtonToolTip(Int32.Parse(productId.ToString()), getCumparaturiCategoryID(im

I have this method in cs page:

public String getToolTip(Object productId, Object imgBtnId)
{
    return UtilsStatic.getWishListButtonToolTip(Int32.Parse(productId.ToString()), getCumparaturiCategoryID(imgBtnId.ToString()));
}

and i want to call it from asp.net page (aspx).

I tried like this but it fails:

 ToolTip="<%# getToolTip(getProductIdNoutatiFeatured(), 'imgBtnWishSubcategory2Featured')%>"/>

Please note that the second parameter is an hardcoded string...but it says:

CS1012: Too many characters in character literal

I think it is wrong to put the string between ' '. But how开发者_JAVA技巧?


You can't use single quotes for a string, you have to reverse the usage of single- and double-quotes:

ToolTip='<%# getToolTip(getProductIdNoutatiFeatured(),
                        "imgBtnWishSubcategory2Featured")%>'/>


It should be

ToolTip="<%# getToolTip(getProductIdNoutatiFeatured(), \"imgBtnWishSubcategory2Featured\")%>"/>


I think as well as the quotes issue you are trying to use the binding <%# %> instead of writing out the result with a starndard response.write

try

'<%=getToolTip(getProductIdNoutatiFeatured(), "imgBtnWishSubcategory2Featured")%>'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号