我正在尝试在asp.net页面上聊天。 我考虑过使用gridview,以便轻松使用数据表并添加一些文本。 最近我被要求放一些表情符号。所以现在我需要知道我是否可以将文本和图像放在同一个单元格中。
我见过其他人在单元格中添加文字而在另一个单元格中添加图片但从未在同一单元格中添加文字和图像
如果不可能,还有其他解决方案或解决方法吗? 提前谢谢
答案 0 :(得分:1)
使用TemplateField:
<asp:gridView...>
<columns>
<asp:TemplateField HeaderText="MyColumn">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("YourCellText") %>'></asp:Label>
<img src='<%#Bind("your image url")%>'/>
</ItemTemplate>
</asp:TemplateField>
</columns>
答案 1 :(得分:1)
我不确定您填充到数据表中的数据类型。正如你提到聊天这个词,我想它就是这样的。
#ifdef
如果是这样,您可以在gettext
内使用var sampleData = "<p>Hello World <img src='http://placehold.it/100x100' /></p>";
来获得所需的结果。
asp:Literal
答案 2 :(得分:0)
In order to handle emoji you need to able to insert them as well as display them. such that what is rendered looks something like this:
<p>This is some text followed by an emoticon
##EmoteMarker## and
some more text.</p>
Where ##EmoteMarker##
is translated by your code to render something similar to this:
<img src="images/emoji/smiley.png"/>
on databind.
Now the trick is to determine where do the images reside?
If your chat users are using some intranet or if the chat program is web based then you can use a basic embedded image in the text and just make sure the html is properly encoded/decoded in the gridview.
however if the app is say smartphone based or is a standalone app then it's likely the emoji are stored local to the device in which case the Marker mus be translated to use local resources of the app rather than a central repository of images
Or...maybe it's a combination of both.
The point is that you may have to parse the text either on input to embed an html image tag or prior to display to convert a marker to a local image/sprite