Link to home
Start Free TrialLog in
Avatar of goodk
goodkFlag for United States of America

asked on

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

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!!
Avatar of prajapati84
prajapati84
Flag of India image

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' />
Avatar of goodk

ASKER

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
Avatar of goodk

ASKER

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>
Avatar of goodk

ASKER

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();

        }  
Avatar of goodk

ASKER


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??
Avatar of goodk

ASKER

basically, I am asking how the form submit works when we are using the master pages
ASKER CERTIFIED SOLUTION
Avatar of prajapati84
prajapati84
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of goodk

ASKER

thanks, it works good!!

why take so long to responsd and help??