将国旗图像与国家名称匹配:

我有一个下拉菜单,其中包含提交给数据库的国家/地区名称。我想在最终用户个人资料上显示该国国旗的图像。我在根目录中有一个包含所有标志图标的文件夹。

我该怎么办?

我能够获取用户的国家/地区名称,但现在我可以使用该名称从图像文件夹中获取图像。

 Flag_image.ImageUrl = "~/images/"countryTESTLabel.Text.ToString.Replace("_", " ")".png";



SMILET
浏览 177回答 2
2回答

饮歌长啸

我有同样的问题,但没有解决方案。我将其追溯到函数中MobileServiceHttpClient代码中的以下代码行SendRequestAsync(...)。// If there was supposed to be response content and there was not, throw&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if (ensureResponseContent){&nbsp; &nbsp;long? contentLength = null;&nbsp; &nbsp;if (response.Content != null)&nbsp; &nbsp;{&nbsp; &nbsp; &nbsp; contentLength = response.Content.Headers.ContentLength;&nbsp; &nbsp;}&nbsp; &nbsp;if (contentLength == null || contentLength <= 0)&nbsp; &nbsp;{&nbsp; &nbsp; &nbsp; &nbsp; throw new MobileServiceInvalidOperationException("The server did not provide a response with the expected content.", request, response);&nbsp; &nbsp;}}看着response.Content.Headers.ContentLength它是null。将应用程序作为 2.0 Core 项目运行,该值已正确填写。奇怪的是内容在那里。如果您深入了解私有成员,其中一些已正确设置。catch (MobileServiceInvalidOperationException msioe){&nbsp; &nbsp; //content will contain the correct json but the ContentLenth is null!?!&nbsp; &nbsp; string content = await msioe.Response.Content.ReadAsStringAsync();}这是一个 2.1 核心问题。希望他们修复它。
打开App,查看更多内容
随时随地看视频慕课网APP