开发者

is it possible to call our server side(like gridview events) event from JavaScript

<img src='<%# "ThumbNailImage.ashx?ImID="+ Eval("ImageID")  %>' id="ImgShow" runat="server"
                                                align="top" style="border: solid 1px Gray;" height="150"  
                                                width="170"  onclick="javascript:myFunction();" >


protected void gvImages_SelectedIndexChanged(object sender,  EventArgs e)
    {

        string s = gvImages.SelectedValue.ToString();
        SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString);
        SqlCommand command = new SqlCommand("SELECT imagename,ImageID from [Image2] where ImageID='"+s+"' ", connection);
        SqlDataAdapter ada = new SqlDataAdapter(command);
        ada.Fill(dt);
        this.dvCustomerDetail.Visible = true;
        dvCustomerDetail.DataSource = dt;
        dvCustomerDetail.DataBind();
        this.updPnlCustomerDetail.Update();
        this.mdlPopup.Show();

    }

 <script  type ="text/javascript" >
    function myFunction()
    {
    debugger ;
document.getElementById('<%=gvImages.ClientID%>').SelectedIndexChanged();
//__doPostBack('Button1','OnClick');

}
    </script>

now in control i a calling my javascript function from there i need to call my gvImages_selected index change event.

which is not happening is there any issue in my j开发者_StackOverflow中文版avascript any help would be great thank you


I don´t think you can call the SelectedIndexChange event like that, you need to trigger it from a button in the grid: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedindexchanged.aspx

You could of course hide the Select button with css, and manually call the click() method of the button in the row you wish to switch the index to.

Wrap it in an UpdatePanel, and set the SelectedIndexChange event of the GridView as a trigger for the UpdatePanel.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜