本文介绍了Javascript无法使用母版页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检查我的下面的代码我正在使用母版页并且我的javascript功能无效..

请找出解决方案..



Check my below code i am using master page and my javascript function is not working..
please find out the solution..

<%@ Page Language="C#" MasterPageFile="~/admin/admin.master" AutoEventWireup="true" CodeFile="Category.aspx.cs" Inherits="admin_Category" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script type="text/javascript" language="javascript">
function Validate(x)
{
if(x.value!='')
{
alert('hello');
return false;
}
else
{
alert('hi');
return true;
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
   <div align="center">

            <table class="mygrid"    cellspacing="0" cellpadding="0" >
            <tr>
            <td>Category Name</td>

            <td>
                <asp:TextBox ID="TextBox1" runat="server" CssClass="form-fill"></asp:TextBox>
  <tr>
            <td></td>
            <td>

                <asp:Button ID="Button1" runat="server" Text="ADD" OnClientClick="return Validate(this)" CssClass="btn" />
                 <asp:Button ID="Button2" runat="server" Text="UPDATE"  Visible="false" CssClass="btn"/>

            </td>
            </td>
            </tr>
  </table>
</asp:Content>



从上面的代码中,如果我没有输入任何值到文本框并输入值到文本框,我得到一个输出为HELLO ... ony


From above code if i run with out entering any values to text box and entering values to textbox i am getting an out put as HELLO...ony

推荐答案

function Validate()
{
  var x =






和OnClientClick: -





and OnClientClick :-

  <asp:button id="Button1" runat="server" text="ADD"

              OnClientClick="return Validate();"      

              CssClass="btn">
</asp:button>





祝你好运。



Good luck.


这篇关于Javascript无法使用母版页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 12:58