问题:使用模型弹出窗口和Web服务弹出图像onclick网格视图图像 [英] problem: popup image onclick gridview image using model popup and web service

查看:54
本文介绍了问题:使用模型弹出窗口和Web服务弹出图像onclick网格视图图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Web服务(如
)发送图像路径(作为图像保存在文件夹中)
[System.Web.Services.WebMethod(),System.Web.Script.Services.ScriptMethodAttribute()]
公共静态字符串GetDynamicContent(string contextKey)
{
string constr =数据源= Subhasish-PC;初始目录= testabhijit;集成安全性= SSPI;";
字符串查询=从imagetable WHERE id ="选择ImagePath + + contextKey;


SqlDataAdapter da =新的SqlDataAdapter(query,constr);
DataTable表=新的DataTable();

da.Fill(table);
字符串x = table.Rows [0] ["ImagePath"].ToString();


返回x.ToString();

}

现在在.aspx页面上,我正在进行面板和图像控制,如下所示

< asp:Panel runat ="server" CssClass ="modalPopup" ID ="panSaving" Style ="display:none">
< table cellpadding ="0" cellspacing ="0" border ="0" width ="100%">
< tr>
< td>
< asp:图片ID ="imgClose" runat =服务器" ImageUrl =''''高度="336"宽度="430"/>
</td>
</tr>

</table>
</asp:Panel>

我的问题是我将如何绑定图像控件的ImageUrl ...,以便可以访问Web服务发送的路径.谢谢.

I am sending image path(as image save in folder) from web service like

[System.Web.Services.WebMethod(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string GetDynamicContent(string contextKey)
{
string constr = "Data Source=Subhasish-PC;Initial Catalog=testabhijit;Integrated Security=SSPI;";
string query = "SELECT ImagePath FROM imagetable WHERE id = " + contextKey;


SqlDataAdapter da = new SqlDataAdapter(query, constr);
DataTable table = new DataTable();

da.Fill(table);
string x = table.Rows[0]["ImagePath"].ToString();


return x.ToString();

}

Now at .aspx page i am taking panel and image control, like below

<asp:Panel runat="server" CssClass="modalPopup" ID="panSaving" Style="display: none">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<asp:Image ID="imgClose" runat="server" ImageUrl='''' Height="336" Width="430"/>
</td>
</tr>

</table>
</asp:Panel>

My problem is how i will bind ImageUrl of image control......so that which path is sending at web service i can access. Thank you.

推荐答案

嗨罗希特,

您可以通过使用javascript调用该网络服务来做到这一点.

以下是代码段.

首先,您必须使用scriptmanager启用PageMethods
< asp:scriptmanager id ="ScriptManager1" runat ="server" enablepagemethods ="true" xmlns:asp =#unknown">


然后编写一个javascript函数来调用webservice



功能测试(contextKey)
{
PageMethods.GetDynamicContent(contextKey,
OnSucceeded,OnFailed);
}
函数OnSucceeded(){
//显示谢谢".
//编写JavaScript代码以绑定图像路径
//var img = document.getElementById(ur image id);
}
函数OnFailed(错误){
//警告用户该错误.
警报(error.get_message());
}

希望对您有帮助
Hi Rohit,

You can do this by calling that webservice through javascript.

Below is the code snippet.

First you have to enable PageMethods using scriptmanager
<asp:scriptmanager id="ScriptManager1" runat="server" enablepagemethods="true" xmlns:asp="#unknown">


then write a javascript function to call the webservice



fubction Test(contextKey)
{
PageMethods.GetDynamicContent(contextKey,
OnSucceeded, OnFailed);
}
function OnSucceeded() {
// Dispaly "thank you."
// write javascript code to bind image path
//var img=document.getElementById(ur image id);
}
function OnFailed(error) {
// Alert user to the error.
alert(error.get_message());
}

Hope this helps


这篇关于问题:使用模型弹出窗口和Web服务弹出图像onclick网格视图图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆