Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 237219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:24:28+00:00 2026-05-11T20:24:28+00:00

The scenario…I have a list of dynamic hyperlink controls on an ajax panel that

  • 0

The scenario…I have a list of dynamic hyperlink controls on an ajax panel that link directly to a WORD doc located on a share. Clicking any link opens WORD client side (I set the file association to do that so the IE browser doesn’t try to open it instead).

LinkButtons won’t work because it doesn’t do a direct link to the doc from the browser and I don’t want server automation or activex, since I want each client to open the doc using their own box as if they had simply clicked on the document itself.

But I need to change an image in an image control once they’ve clicked on the hyperlink. In other words, I need the link to sit on top of a control that does cause a postback so I can get at the posting controls ID and do my thing. I’m also trying to avoid client side scripting though I’m sure there may be a convoluted way to do that.

Here is the code in the loop that creates the dynamic link. I started with just the hyperlink control, then this code is messing with adding a hyperlink to a label, that’s why it’s showing as it is:

Label lblWordLink = new Label();
HyperLink hrefLetter = new HyperLink();
hrefLetter.Text = items.letterName;                
hrefLetter.NavigateUrl = folderForPackageLetters + items.letterName + wordDocExtension;
hrefLetter.ID = "standardLettersHref_" + items.letterName;
lblWordLink.Text = "<a href='" + hrefLetter.NavigateUrl.ToString() + "'>" + items.letterName + "</a>" ;                
tRow.Cells[1].Controls.Add(lblWordLink);

I’m looking for a way to let the link open the doc and at the same time postback. Is there a way to layer the link control on top of another control such that the link just links and the control beneath causes a postback?

32U

Fixed: the answer gave the clue. On the server, during dynamic control creation I did:

HyperLink hrefLetter = new HyperLink();
hrefLetter.ID = "standardLettersHref_" + items.letterName;
hrefLetter.Text = items.letterName;                
hrefLetter.NavigateUrl = folderForPackageLetters + items.letterName + wordDocExtension;                               
hrefLetter.Attributes.Add("OnClick", "letterHrefClick('" + items.letterName + wordDocExtension + "')");
tRow.Cells[1].Controls.Add(hrefLetter);

then client side I pushed a value into a hidden control inside the ajax panel when the hyperlink control was clicked and forced submit:

function letterHrefClick(link) {
  //alert(link);
  form1.hdnLetterClick.value = link;
  form1.submit();
}

After the submit, back on server side, I got the value in the Page_Load event:

 string x = hdnLetterClick.Value;

nice!

update…
An even better way to do this… in the javascript postback use:

__doPostBack("hdnLetterClick", "somevalue");

then in the codebehind in the Page_Init you can do (not for button or imgbutton):

string postbackControlID = Request.Params.Get("__EVENTTARGET");
string postbackArgument = Request.Params.Get"__EVENTARGUMENT");

to get at what you need. This is better if dealing with dynamic controls so you can control state during control recreation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:24:28+00:00Added an answer on May 11, 2026 at 8:24 pm

    If you give your link an onclick attribute, those javascript actions should also be executed when the link is selected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario: I have an application that pulls data from a SQL database as well
Scenario Imagine a REST service that returns a list of things (e.g. notifications) Usage
Scenario: I have an application that has a config table which stores the config
Scenario: I have a directory on a server that hosts my website that contains
Scenario: I have a blog that I want to make a post to. I
Scenario: I have a TFS Build (TFS2008) that has several targets override: BuildNumberOverrideTarget, AfterGet,
Scenario: I have a webpage that needs to make XMLRPC calls from Javascript, and
Scenario: You have an ASP.Net webpage that should display the next image in a
Scenario: Every page on the website will have a menu bar at the top
Scenario 1: If I have a Great Grandpa ancestor (let's name him A); And

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.