我正在写一些添加一些链接属性,如下所示。哪个呈现为 HTML,但我想知道我可以在按钮单击事件中访问这些属性值吗?
我的代码如下
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem gridDataItem = (GridDataItem)e.Item;
gridDataItem.Height = Unit.Pixel(10);
HyperLink link = (HyperLink)gridDataItem["ContentTitle"].Controls[0];
ViewState["ContentID"] = gridDataItem["ContentID"].Text;
link.ForeColor = System.Drawing.Color.Navy;
link.ToolTip = Common.grdTextCell(gridDataItem["ContentSummaryDescr"].Text);
link.NavigateUrl = "~/SlideImages/" + gridDataItem["ContentName"].Text;//Session["contentFolderPath"] + "\\"+ gridDataItem["ContentName"].Text;// Common.grdTextCell(gridDataItem["ContentName"].Text);
link.Target = "_blank";
link.Attributes["name"] = gridDataItem["ContentID"].Text + "," + gridDataItem["SiteContentListID"].Text;
HttpResponse myHttpResponse = Response;
HtmlTextWriter myHtmlTextWriter = new HtmlTextWriter(myHttpResponse.Output);
link.Attributes.AddAttributes(myHtmlTextWriter);
link.Attributes.Add("onclick",
"document.getElementById('" +
dummyBtn.ClientID + "').click();");
}
}
protected void dummyBtn_Click(object sender, EventArgs e)
{
}
渲染的 HTML 是这样的..
我正在写这一行
<td><a style="color:Navy;" target="_blank" href="somepath/abc.doc" onclick="document.getElementById('MainContent_SiteNewCon_dummyBtn').click();" name="1,16" title="rupesh tesr">test</a></td>
我想将 thses name="1, 16" 用于我的按钮单击事件,以便我可以将它们保存到数据库。