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

I have this method on the 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 the asp.net (aspx) page.

I tried like this, but it fails:

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

Note that the second parameter is a string string ... but it says:

CS1012: Too many characters in a literal character

I think it is wrong to put a line between. '' But how?

+3
source share
3 answers

You cannot use single quotes for a string, you need to reverse the use of one and two quotes:

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

It should be

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

, , , <% #% > , starndard response.write

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

Source: https://habr.com/ru/post/1735478/


All Articles