Link to home
Start Free TrialLog in
Avatar of NickMalloy
NickMalloyFlag for United States of America

asked on

HTML Controls question

Is there a way though a regular page link like this <a runat="Server" href="http://www.yahoo.com">This is a link </a> with runat server added to call an asp.net sub routine and pass whatever text is where "This is a link" to it for a SQL query??
Avatar of thrill_house
thrill_house
Flag of United States of America image

Yes this is possible.  You just need to reference the control in the code behind by declaring it like this:

Protected WithEvents myHTMLlink As System.Web.UI.HtmlControls.HtmlAnchor


Some of the events have slightly different names, but you should be able to figure it out.  Just make sure the HTML control has a runat="server" attached to it.
Avatar of NickMalloy

ASKER

My link is going to be created from XML using XSL, so I won't know the name of the link.
Can you explain the process you are using to get the data from XML to the asp.net page?  It's possible that you might be able to intercept it somewhere and do it.  
I have a form I am working on which will be filled out based on returns the company makes. Part of this form is vendor information. My users do not want to have to deal with dropdownlist since we have well over 5000 vendors. So I was thinking of implementing a search function like this

http://blog.bitflux.ch/wiki/LiveSearch

When the user types a vendor it will narrow down to the vendors name and the different contacts with that vendor. I want the user to be able to select the vendors name and have there contact information fill in the rest of the form. So some how from what name they click I need the contact information to fill in the rest of the form. So I want to hit a sub and fill in the rest of the information.
What you can do is set up a literal where you want the link to be.  Then cause a postback to occur when they select a vendor.  On the event that happens when they select the vendor you can just set the contents of the literal to "<a href='" & vendorLoc & "'>" & vedorName & "</a>"

Something like that is a nice work around, and no one will know the difference.
I don't think I quite understand that. Can you show me an example or point me to one.  Thanks
Ok, so let me see if I understand you.  They will do a search for the vendor, which will cause a postback when they his the "search" button.

You will have a literal on your html side, lets just call it literal1

When you get the results from the search, just do this:
Literal1.text = "<a href='" & vendorLoc & "'>" & vendorName & "</a>"
Where vendorLoc is the URL you want to send the person, and vendorName is the name of the vendor


Or is this search feature done entirely client side?
There is no postback to the server. If you look at the link above. When the user types letters on there keyboard it fires a javascript which will call a ASPX page. This page will load a dataset and then place it as XML. The XML is transformed into HTML using XSL and displayed in a DIV. The article above will explain it a little better I am sure. there is no postback from the users point of view.
Ok I think I understand a little bit more of what you are trying to do.  Are you basically trying to implement a LinkButton in html?  It seems like you want something that looks like a hyperlink that will cause a postback event that calls a SQL query.  Is this correct?
Yeap that is it.
Ok, I've done something like this before... what I did was mimic what ASP.net does by manually calling a javascript method to do a postback (as the href).  I then check for the value that is thrown back on page load, and do work accordingly.  I will try and get an example for you.
thank you. I will look forward to seeing your example
Ok,
I've been trying to recreate what I was doing before and I have been able to do it.  However, do you have the ability the modify the id of the "linkbutton" to be equivalent to the value you want to query in your database?  If you can, then what I did will definitely work.  If not, I'm afraid it might not be able to.  So can you assign the value of the id equal to the vendor information you want to query?
sure. I can format the link using XSL to look however I want
ASKER CERTIFIED SOLUTION
Avatar of thrill_house
thrill_house
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial