I want to use the input button - How do I see the value on the form submit

goodk
goodk used Ask the Experts™
on
this part is inside the form,

   <input type="button"  runat="server" id="t1id" value="how do you see this value if changed"  />

   <input type="button"  runat="server" id="t2id" value="how do you see this value if changed"  />

on call back,
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write("id= " + HttpContext.Current.Request.Form["t1id"]);
}

the above only work for the button I click - how do I see the value if I do not click it but click t2 button?  REALIZE I AM NOT USING ASP buttons!!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi goodk,

HTML button posts the values inside FORM tag except other buttons to identify which button is clicked.
But there is an alternative, you can use a input hidden field to store the value of a button.
e.g.
<input type='hidden' id='hdnB1' name='hdnB1' value='Button1 text' />
<input type='hidden' id='hdnB2' name='hdnB2' value='Button2 text' />

Author

Commented:
Hi thanks,
in my case I show the dates on button and then on the client side two buttons acquire a new date through date picker.  

When I click the submit button,  I want to use those values.

. Please help

Author

Commented:
here is my code, there are no value appear when I do response.write

<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write("Date= " + HttpContext.Current.Request.Form["t"]);

    }

</script>
   

    <link href="../jquery/jquery-Calendar.css" rel="stylesheet" type="text/css" />
    <script src="../jquery/jquery-1.5.2.js" type="text/javascript"></script>
    <script src="../jquery/jquery-ui-1.8.9.js" type="text/javascript"></script>  <script type="text/javascript">
        $(document).ready(function() {
            $("#datepicker").datepicker();
        });

        $(document).ready(function() {
            $("#t").datepicker();
        });
       
       
       
    </script>

</head>
<body>
    <form id="form1" runat="server">

    <input type="button" name="t" runat="server" id="t" value="04/04/2011" onclick='$( "#t" ).datepicker( "show");' />
    <asp:Button ID="Button1" runat="server" Text="Button" />
     </form>
</body>
</html>
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

Author

Commented:
I kind of figured out that I have to equate hidden fields to displayed button field,  so I did the following.

I am facing a small problem though.  when I use the master page, and the form is located in it. It is not working, that is it does not know form1?

How to resolve this?

   
    function submitform() {

            form1.hCal1.value = form1.Cal1.value;
            form1.hCal2.value = form1.Cal2.value;
            document.form1.submit();

        }  

Author

Commented:

I HAD TO USE aspnetForm for the form name - WHAT THE HELL this asp.net is?????

even though the name of my form is form1 - Where are the experts??

Author

Commented:
basically, I am asking how the form submit works when we are using the master pages
Try this, it should work:

   function submitform() {
            document.getElementById('hCal1').value = document.getElementById('Cal1').value;
            document.getElementById('hCal2').value = document.getElementById('Cal2').value;
            document.forms[0].submit();
        }  

Author

Commented:
thanks, it works good!!

why take so long to responsd and help??

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial