开发者

how to call javascript function

when i click on the textbox which is inside the item template of gridview then onclick event should fire and then call the javascript function but my problem is that there no onclick event option in item template's textbox plz hel p me.

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" OnRowCommand="GridView2_RowCommand"
                Width="100%" GridLines="None" 
                style="font-family: Tahoma; font-size: xx-small" Font-Names="Tahoma" 
                Font-Size="XX-Small">
                <Columns>      
                    <asp:BoundField HeaderText="Status" DataField="Status" HeaderStyle-HorizontalAlign="Left"
                        ItemStyle-HorizontalAlign="Left">
                        <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Left"></ItemStyle>
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="Order" >
                    <ItemTemplate>
                    <asp:TextBox ID="TextBox1" Text='<%#Eval("ArticleOrder")%>' ReadOnly="true"  
                            runat="server" Height="18px" Width="16px" onclick="hello();" >
                            </asp:TextBox>
                    </ItemTemplate>                           
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:TemplateField>
                    <%--<asp:BoundField HeaderText="Order" DataField="ArticleOrder" HeaderStyle-HorizontalAlign="Center"
                        ItemStyle-HorizontalAlign="Center">
                        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>--%>
                    <asp:BoundField HeaderText="Title" DataField="ArticleTitle" HeaderStyle-HorizontalAlign="Left"
                        ItemStyle-HorizontalAlign="Left">
                        <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Left"></ItemStyle>
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="Edit" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate&开发者_JAVA技巧gt;
                            <asp:ImageButton ID="ImageButtonedt" runat="server" ImageUrl="~/images/newspaper_go.png"
                                CommandName="edt" CommandArgument='<%#Eval("ArticleID")%>' />
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Delete" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:ImageButton ID="ImageButtondel" runat="server" ImageUrl="~/images/newspaper_delete.png"
                                CommandName="del" OnClientClick='return confirm("Are you sure you want to delete ?");' CommandArgument='<%#Eval("ArticleID")%>' />
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>

javascript function:

hello()
{
var divName = document.getElementById('div1');
        var divFade = document.getElementById('fade');
        divName.style.display = 'block';
        divFade.style.display = 'block';
}  


Cant tell from you code.. but if thats exactly what you have you need to define your javascript function as a function:

function hello() { 
     var divName = document.getElementById('div1');         
     var divFade = document.getElementById('fade');         
     divName.style.display = 'block';         
     divFade.style.display = 'block'; 
}   

also, 'div1' and 'fade' are not defined in your code

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜