在EditItemTemplate中使用JavaScript [英] Using javascript in EditItemTemplate

查看:107
本文介绍了在EditItemTemplate中使用JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用JS日历,但即使我已经测试过"displayDatePicker(''<%= Date.ClientID%>'',this);也不行.但是Visual Studio会收到此错误:当前contex中不存在名称"Date"
我该怎么办?请指导我.

I want to use JS calendar but it does''nt work, even I''ve tested "displayDatePicker(''<%=Date.ClientID%>'',this);" but visual studio gets this error: The name''Date'' does not exist in the current contex
what should I do?please guid me.

<EditItemTemplate>
         <asp:Panel ID="Panel9" runat="server" Width="80%">
              <table width="100%">
                 <tr>
                    <td width="30%">Title:<br />
                      <asp:TextBox Font-Bold="true" ID="Title" runat="server"

                             Text='<%# Bind("Title") %>' Width="100" /></td>
                    <td width="55%">Date:<br />
                      <asp:TextBox  Font-Bold="true" ID="Date" runat="server"

                            Text='<%# Bind("Date_e") %>' Width="150" /> </td>
                    <td><img alt=""  önclick="displayDatePicker('<%=Date.ClientID%>',this);"  src="Images/calendar.jpg" style="width: 19px" /></td>
                                        </tr>
                                    </table>
                                </asp:Panel>
 </EditItemTemplate>

推荐答案

首先将ID从"Date"更改为"myDate"之类.
然后出现错误,可能是因为文本框位于编辑模板"中.

最简单的解决方法可能是:我建议您制作一个具有一个文本框和一个图像的用户控件(只需将上面的内容剪切粘贴到其中),然后在此处使用该用户控件即可.那应该做.尝试.
First of all change the ID from ''Date'' to something else like ''myDate'' or so.
Then the error comes probably because the textbox is in the ''edit template''.

Simplest resolution could be: I would suggest you to make a usercontrol that has one textbox and one image (just cut paste the above thing into it) and then use that usercontrol here. That should do. Try.


在文本框ID之前放置 Gridview 名称,因为它位于gridview itemtemplate内.

使用
Put Gridview name before the textbox ID since it''s inside of gridview itemtemplate.

Use
<img alt="" onclick="displayDatePicker('<%= GridView1.Date.ClientID%>',this);"  src="Images/calendar.jpg/>


代替


instead of

<img alt="" onclick="displayDatePicker('<%= Date.ClientID%>',this);"  src="Images/calendar.jpg"/>


就是这样.


That''s all.


请给我发送图像的ID

您的代码:
Please send me the id of Image

your code:
<img alt=""  önclick="displayDatePicker('<%=Date.ClientID%>',this);"  src="Images/calendar.jpg" style="width: 19px" />



更新的代码:



updated code:

<asp:Image runat="server" id="imgDate" onclick="alert(this.id);" ImageUrl="Images/calendar.jpg" style="width: 19px" />



请向我发送将在警报消息中显示的ID.然后,我会给您解决方案.


谢谢,
Imdadhusen



Please send me the id that will be displayed in Alert message. Then i will giving you solution.


Thanks,
Imdadhusen


这篇关于在EditItemTemplate中使用JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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