Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
structure is somithing like this,
objDiv gets visible when we click on Book Now button i want to get reference of txtSeatNo texbox in aa() which is a javascript function.
XML
I tried much and went through many of forum  but no use, can any one help me


    <asp:DataList ID="dlObject" runat="server">
        <ItemTemplate>
            <table>
                <tr>
                    <td>
                        <asp:Label ID="lblCompanyName" runat="server" Text='<%#Eval("CompanyName") %>'></asp:Label>
                    </td>
                    <td>
                        <asp:Label ID="lblBusType" runat="server" Text='<%#Eval("ArrangementName") %>'></asp:Label>
                    </td>
                    <td>
                        <asp:Button ID="btnBookNow" runat="server" Text="Book Now" />
                    </td>
                </tr>
                <tr>
                    <td colspan="3">
                        <div visible="false" id="objDiv" runat="server">
                            <table>
                                <tr>
                                    <td>
                                        <img src="Images/somepic.gif" onclick="aa()" />
                                    </td>
                                    <td>
                                        Seat No
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtSeatNo" runat="server" CssClass="hideBorder" onKeyPress="return false"></asp:TextBox>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </td>
                </tr>
            </table>
        </ItemTemplate>
    </asp:DataList>


<script>
function aa()
{
var objSeatNo = <pre lang="xml">document.getElementById(&#39;&lt;%=txtSeatNo.ClientID %&gt;&#39;);
objSeatNo
}

&lt;/script&gt;</pre>.value = "5";
Posted

hi try this

var objSeatNo = <pre lang="xml">document.getElementById(&#39;&lt;%=txtSeatNo.ClientID %&gt;&#39;);


change the above line to

var objSeatNo = document.getElementById("txtSeatNo").val();


you can get the value of txtSeatNo to ObjSeatNo.
 
Share this answer
 
Comments
NAPorwal(8015059) 29-Oct-12 2:35am    
Thanks for ur reply but its not working i have to set value to the textbox of selected index as it is inside daltalist
Naga KOTA 29-Oct-12 2:40am    
hi
check out the following link
http://stackoverflow.com/questions/9013377/adding-value-to-textbox-inside-datalist-itemtemplate

may be useful for you
NAPorwal(8015059) 29-Oct-12 5:26am    
Hi knvsatyanarayana,

Thank you for giving me idea of using val(). since i have done it in another way, but its you who made me think in this way and now its working fine

Thank allot.

I did it like this..

$("#ctl00_ContentPlaceHolder1_dlRouts_ctl0"+indx+"_txtSeatNo")val('new value');
indx is the selected index no of datalist which i saved on a lable

XML
var clienttype = document.getElementById('<%=lblDivlastIndx_Itm.ClientID %>').value;
var indx = parseInt(clienttype);
indx=indx+1;




$("#ctl00_ContentPlaceHolder1_dlRouts_ctl0"+indx+"_txtSeatNo").val('New Value');

Now its working fine.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900