Solved

asp.net and javascript link submit

Posted on 2014-09-24
2
218 Views
Last Modified: 2014-09-25
<asp:DropDownList runat="server" ID="brand">
                                                <asp:ListItem selected="True" Text="HP" Value="HP"></asp:ListItem>
                                                <asp:ListItem Text="Canon" Value="Canon"></asp:ListItem>
                                            </asp:DropDownList>



<asp:DataList Width="800px" runat="server" ID="dataListBrand" RepeatColumns="8" RepeatDirection="Vertical" >
                                            <ItemTemplate>
                                             <li>
                                             <a href="Brand.aspx?Name=<%# Eval("name") %>">
                                             <asp:Label Width="140px" runat="server" ID="repeatListItemCategory" Text='<%# Bind("name") %>'></asp:Label>                                            
                                             </a>
                                             </li>
                                            </ItemTemplate>
                                            </asp:DataList>        


 

If <a href="Brand.aspx?Name=<%# Eval("name") %>"> is clicked, it is a link then I
want to capture both values from <a href="Brand.aspx?Name=<%# Eval("name") %>"> and brand.

How can I do that?
0
Comment
Question by:ITsolutionWizard
2 Comments
 
LVL 2

Accepted Solution

by:
Vishal Patil earned 500 total points
Comment Utility
Hello  ITsolutionWizard,

Please check with following code:

Javascript:
    <script type="text/javascript">
        function SayHello(txt, contact) {
            document.getElementById("<%= brand.ClientID %>");
            alert(document.getElementById("<%= brand.ClientID %>").value);
            alert(txt);
            window.open(contact, "Tesst");
            return false;
        }
    </script>

Open in new window


Source :

<asp:DropDownList runat="server" ID="brand">
        <asp:ListItem Selected="True" Text="HP" Value="HP"></asp:ListItem>
        <asp:ListItem Text="Canon" Value="Canon"></asp:ListItem>
    </asp:DropDownList>
    <asp:DataList Width="800px" runat="server" ID="dataListBrand" RepeatColumns="8" RepeatDirection="Vertical">
        <ItemTemplate>
            <li><a href="" onclick='javascript:return SayHello("<%# Eval("name") %>","Brand.aspx?Name=<%# Eval("name") %>");'>
                <asp:Label Width="140px" runat="server" ID="repeatListItemCategory" Text='<%# Bind("name") %>'></asp:Label>
            </a></li>
        </ItemTemplate>
    </asp:DataList>

Open in new window

0
 

Author Closing Comment

by:ITsolutionWizard
Comment Utility
quick and accurate.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now