刚入门学做动态网页,做好了页面设计,但是不知道用什么函数或类可以吧点击按钮的动作返回作为.aspx.cs里面的值,求助。。

解决方案 »

  1.   

    直接使用HTML按钮或服务器端按钮click事件
    http://topic.csdn.net/u/20091109/20/2fabfb02-172e-40ce-ae8f-d0ff2523c58f.html?seed=2065155958&r=61113547
      

  2.   

    估计楼主是不会JavaScript的。双击你拖出来的那个button,然后就会自动跳转到cs页面,并自动创建一个单击事件,在单击事件里面写代码吧,这个事件就是指点击那个button的时候触发的事件
      

  3.   


    button
    lable
    函数
    OK了
      

  4.   


    我看了那个帖子的代码,用她的原代码做出的网页计数器挺好,但是把ID改成我网页里的,用同样的代码,就出现问题了.
    protected void Button13_Click(object sender, EventArgs e)
      {
      Button B1 = (Button)sender;
      if (this.TextBox1.Text != "0")
      this.TextBox1.Text += B1.Text;
      else
      this.TextBox1.Text = B1.Text;
      }说B1无法转换成string类之类的..
    吧else语句去掉可以正常输入数字,但是按了清除键以后,就再也没法输入数字了,刷新页面也没用.郁闷啊!
      

  5.   

    直接javascript还用的着去服务器整,那样还慢
      

  6.   

    给你发个代码吧,你用用看,用JS实现的
    <center><table border="0" cellspacing="0" cellpadding="0" width="0" >
    <tr>
    <td width="100%" valign="top"><table border="2" width="300" cellspacing="0"ellpadding="0" bgcolor="#000000" style="border-color:black"
    onClick="previouskey=event.srcElement.innerText">
    <tr>
    <td width="100%" bgcolor="#FFFFFF" id="result"
    style="font:bold 20px Verdana;color:black;text-align='right'">0</td>
    </tr>
    <tr>
    <td width="100%" valign="middle" align="center"><table border="0" width="100%"
    cellspacing="0" cellpadding="0" style="font:bold 20px Verdana;color:white">
    <tr><td width="80%" align="center"><table border="1" width="100%" cellspacing="0"
    cellpadding="0" style="cursor:hand;font:bold 20px Verdana;color:white"
    onMouseover="if (event.srcElement.tagName=='TD')event.srcElement.style.color='yellow'"
    onMouseout="event.srcElement.style.color='white'" onselectStart="return false"
    onClick="calculate()" height="82">
    <tr><td width="25%" align="center" height="17">7</td>
    <td width="25%" align="center" height="17">8</td>
    <td width="25%" align="center" height="17">9</td>
    <td width="25%" align="center" height="17">/</td>
    </tr><tr><td width="25%" align="center" height="19">4</td>
    <td width="25%" align="center" height="19">5</td>
    <td width="25%" align="center" height="19">6</td>
    <td width="25%" align="center" height="19">*</td>
    </tr><tr><td width="25%" align="center" height="19">1</td>
    <td width="25%" align="center" height="19">2</td>
    <td width="25%" align="center" height="19">3</td>
    <td width="25%" align="center" height="19">-</td>
    </tr><tr><td width="25%" align="center" height="19">0</td>
    <td width="25%" align="center" height="19"
    onClick="pn();previouskey=1;event.cancelBubble=true">+/-</td>
    <td width="25%" align="center" height="19">.</td>
    <td width="25%" align="center" height="19">+</td>
    </tr></table>
    </td><td width="20%"><div align="left"><table border="1" width="100%" cellspacing="0"
    cellpadding="0"><tr><td width="100%" style="cursor:hand;font:bold 20px Verdana;color:white;text-align:center"
    onClick="result.innerText=0;results=''">C</td>
    </tr></table></div><div align="left"><table border="1" width="100%" cellspacing="0" cellpadding="0"
    height="81">
    <tr><td width="100%" style="cursor:hand;font:bold 32px Verdana;color:white;text-align:center"
    onMouseover="event.srcElement.style.color='yellow'"
    onMouseout="event.srcElement.style.color='white'" onClick="calculateresult()">=<script
    language="JavaScript1.2">var results=''
    var previouskey=''
    var re=/(\/|\*|\+|-)/
    var re2=/(\/|\*|\+|-){2}$/
    var re3=/.+(\/|\*|\+|-).+/
    var re4=/\d|\./
    var re5=/^[^\/\*\+].+\d$/
    var re6=/\./
    function calculate(){
    if (event.srcElement.tagName=="TD"){
    if (event.srcElement.innerText.match(re4)&&previouskey=="=")
    results=''
    if (result.innerText.match(re3)&&event.srcElement.innerText.match(re)){
    if (!results.match(re5)){
    result.innerText="Error!"
    return
    }
    results=eval(results)
    if (results.toString().length>=12&&results.toString().match(re6))
    results=results.toString().substring(0,12)
    result.innerText=results
    }
    results+=event.srcElement.innerText
    if (results.match(re2))
    results=results.substring(0,results.length-2)+results.charAt(results.length-1)
    result.innerText=results
    }
    }
    function calculateresult(){
    if (!results.match(re5)){
    result.innerText="Error!"
    return
    }
    results=eval(results)
    if (results.toString().length>=12&&results.toString().match(re6))
    results=results.toString().substring(0,12)
    result.innerText=results
    }
    function pn(){
    if (result.innerText.charAt(0)!='-')
    result.innerText=results='-'+result.innerText
    else if (result.innerText.charAt(0)=='-')
    result.innerText=results=result.innerText*(-1)
    }
    </script>
    </center>
      

  7.   

    用Button_click事件。
    在页面上拉十个按钮,分别把Text属性设置为0-9,再用一个Label,每个数字按钮按下时都分别执行Label1.Text+="1";
    Label1.Text+="2";
    Label1.Text+="3";
    Label1.Text+="4";
    ......