在asp.net中捕获href事件
So currently here is my code (This is A menu bar that's why i cant use asp link buttons)
所以目前这里是我的代码(这是一个菜单栏,这就是为什么我不能使用asp链接按钮)
<ul>
<li><a href="#"><span>Reconciliation</span></a>
<ul>
<li><a href="#"><span>Double Entry Per Total Expired</span></a></li>
<li><a href="#"><span>Additional Pulled Out Item per Printed SOR</span></a></li>
<li><a href="#"><span>Reclassification to proper account</span></a></li>
<li><a href="#"><span>Additional ren/red after expiry</span></a></li>
</ul>
</li>
<li><a href="#"><span>Reports</span></a>
<ul>
<li><a href="ReportPages.aspx"><span>Report Generation</span></a></li>
<li><a href="PrendaDEPage.aspx"><span>Upload Prenda</span></a></li>
<li><a href="NavFilesPage.aspx"><span>Navision Uploader</span></a></li>
</ul>
</li>
<li><a href="#" class="last"><span>Maintenance</span></a>
<ul>
<li><a href="UsersMaintenancePage.aspx"><span>Report Matrix</span></a></li>
<li><a href="BranchMaintenancePage.aspx"><span>Branches</span></a></li>
<li><a href="AuditTrailPage.aspx"><span>Audit Trail</span></a></li>
</ul>
</li>
</ul>
i want to add a session variable after i click the <a href>
tag but i do not know how to catch the event in asp.net code behind i tried making it runat="Server"
but i cannot find any onclick event that i can use for it to work..
我想在点击标签后添加一个会话变量,但我不知道如何在asp.net代码后面捕获事件我尝试使其运行=“服务器”但我找不到任何onclick事件我可以用它来工作..
Any ideas?
有任何想法吗?
basically the flow i want to achieve is
Click href -> Create a session Variable Session["A"] -> response.redirect to my page.
基本上我想要实现的流程是点击href - >创建会话变量会话[“A”] - > response.redirect到我的页面。
EDIT: The top part menu with <a href = #>
are the ones i need to track and provide a session variable after i click them before i response redirect them into another page. That's why i also used #
instead of the name of the page in order to, and hopefully catch the <a href>
on click event if there is any.
编辑:的顶部菜单是我需要跟踪并提供会话变量后我点击它们之前我响应将它们重定向到另一个页面。这就是为什么我也使用#而不是页面的名称,并希望在点击事件中捕获,如果有的话。
1 个解决方案
#1
2
change to LinkButton
like below
如下所示更改为LinkButton
<li><asp:LinkButton ID="MyLink" runat="server" OnClick="MyLink_Click" Text="Double Entry Per Total Expired"></asp:LinkButton></li>
then you can do the rest in the click event
那么你可以在点击事件中完成剩下的工作
void MyLink_Click(Object sender, EventArgs e)
{
Session["A"] = "put some value here";
Response.Redirect (myURL, false);
}
Anyway if you can't use LinkButton try using onserverclick
event like below
无论如何,如果你不能使用LinkButton尝试使用如下的onserverclick事件
<li><a href="#" onserverclick="MyLink_Click" runat="server" id="MyLink"><span>Double Entry Per Total Expired</span></a></li>
in your code file
在你的代码文件中
void MyLink_Click(Object sender, EventArgs e)
{
// your code
}
更多相关文章
- 使用JQuery显示和隐藏不同div的onClick事件
- fullcalendar.js - 在按钮点击时删除事件
- 使用jquery 1.11.3.min.js时,jquery on click事件未触发。
- bootstrap,模态对话框,shown.bs.modal事件不会触发
- 更改html隐藏字段的事件
- 如何从SQL SELECT查询中的c#变量创建jQuery数组
- JQuery 总结(3) jQuery 各种事件
- jQuery 选择器 与 事件
- 将CSS样式转换成JS变量?