Hi SO:
I am working on a FYI page that has large list of top-tiered links. Under these top-tier links, there are more links that usually go out to external websites. Currently, the way I handle populating the second-tier is as such: I query my database for all the top-tier links, then I construct an unordered list. Each list item has the format of:
<li class="multicolumnlistitem"><a href="linkpage.aspx?s={0}">Link Text</a></li>
Where {0} is the ID of the item. I would like to eliminate the need to pass the ID in the URL. It was suggested to me that I use client-side scripts to dynamically fill a hidden field with the value when one of the links are clicked, then read the form value on the linkpage.
Any ideas/examples/resources will be greatly appreciated.
Thanks!
Update
Here is the code that I have gotten down so far:
<form id="stateform" action="StateFyi/StateFyiView.aspx" method="post">
<p>
<input type="hidden" id="idfield" name="s" runat="server" />
<%
GSDataLayer.Fyi.States StateManager = new GSDataLayer.Fyi.States();
var stateList = StateManager.GetStateList();
foreach (GSDataLayer.Fyi.States.State s in stateList)
{
stateListOutput.Text +=
string.Format("<li class=\"multicolumnlistitem\"><a href=\"javascript:document.getElementById('{0}').value='{1}';document.stateform.submit();\">{2}</a></li>\n",
new string[] {idfield.ClientID, s.ID.ToString(), s.Name});
}
%>
<ul class="multicolumnlist">
<asp:Literal ID="stateListOutput" runat="server" Text="No Items!" />
</ul>
</p>
</form>
The only remaining hurdle is the javascript (either in the above format, or the original document.getElementById('stateform')
) returns null for the form. I cannot add "runat=server" to this form as there is already a form on the page. This preexisting form is required by the CMS I am using to function properly. Any ideas on where to go from here?
Thanks!