View Full Version : Program links into a textbox

05-14-2007, 10:37 PM
Ok, new at this so let see if I can ask the correct question.

I have placed a textbox on my website, I wish to have my clients type a promotional code into the textbox (of which I have many), the promotional code then will link them to the correct page in the website. so I guess my question is how do I code this into the html code. I'm use Visual Studio 2005
Thanks, WineGuy

05-14-2007, 11:33 PM
And the logic behind your promo code to html page is...?
You have to have logic first. Then you code it.

05-15-2007, 12:56 AM
I customize my program for different groups & companies

05-15-2007, 06:25 AM
Ok don't know where you are pulling your promotional codes from? Database, or a hard code?

If you are hard coding these promotional codes then you may want to use a case select. If you are calling the codes from a database you would loop through it until you hit a match.

You could put a <asp:HyperLink ID="HyperLink1" runat="server"></asp:HyperLink> on your aspx page a long with a text box and a button. On button click event you would put in your select case.

and on the code behind page you could put a select case.

Select Case myPromotional
Case CoDe123
HyperLink1.NavigateUrl = "page1.aspx"
HyperLink1.Text = "Please Click This link"
Case CoDe234
HyperLink1.NavigateUrl = "page2.aspx"
HyperLink1.Text = "Please Click This link"
Case CoDe345
HyperLink1.NavigateUrl = "page3.aspx"
HyperLink1.Text = "Please Click This link"
End Select

The problem with going that way is everytime you want to change the Promotional codes or links you would have to hard code the change. If it was me I would setup a database and would call the promotional codes along with the links. I would code an Admin page so I could change my promotional codes and/or links, could add more promotional codes to it and remove some if I needed to.

Anyway this should help to get you thinking of which way would be the easyest and best for you.

05-15-2007, 03:15 PM
I customize my program for different groups & companies

Right, so you have a promo code, but how do you want it to link to a specific page? Like, the page corresponds to a code, and that's stored in the database as a table relationship, or ...?

Freon22 gave you a good start there, except you don't need to loop through to match a record. You just use a where clause. :D