Changing Links - VB - ASP.NET | Newbie | | Join Date: Oct 2008
Posts: 6
| | |
Hey,
New to asp and I need some help.
I created a jump menu that links to different portals. Each portal has all the same images/text, but I wanted to change all the links on each portal to match up with the selection from the jump menu. How would I go about doing that?
Thanks
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | re: Changing Links - VB - ASP.NET Quote:
Originally Posted by IloveTacos Hey,
New to asp and I need some help.
I created a jump menu that links to different portals. Each portal has all the same images/text, but I wanted to change all the links on each portal to match up with the selection from the jump menu. How would I go about doing that?
Thanks That depends on a lot of things. Show me your code, especially how your page currently looks (with all the same images and text), how you have your links stored etc.
Jared
| | Newbie | | Join Date: Oct 2008
Posts: 6
| | | re: Changing Links - VB - ASP.NET Quote:
Originally Posted by jhardman That depends on a lot of things. Show me your code, especially how your page currently looks (with all the same images and text), how you have your links stored etc.
Jared
www.gotoog.com/test.asp is the homepage.
www.gotoog.com/beauty_health.html is an example page. When someone selects a representative I want the all the links on the page to change. I don't really know how to code it so I don't have any code yet, cause I just started learning, but I don't want to have to create 30 pages.
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | re: Changing Links - VB - ASP.NET Quote:
Originally Posted by IloveTacos www.gotoog.com/test.asp is the homepage.
www.gotoog.com/beauty_health.html is an example page. When someone selects a representative I want the all the links on the page to change. I don't really know how to code it so I don't have any code yet, cause I just started learning, but I don't want to have to create 30 pages. So if I select a representative, and then click a link you want the selection I made to be passed on to the server? I didn't dig really deep into your code, but it looks like you already submit the form as soon as the user makes a selection. If this is the case, all you have to do is add that info to the links: - <a href="site.com/somepage.asp?rep=<%=request("representative")%>">somepage.asp</a>
Does this make sense?
The next simplest solution would be to have the place the select drop down in an iframe - submit the form doesn't renew the whole page, but you could store the info on the server as a session variable, or on the browser as a cookie. The cookie or session variable is then available every time a script generates a page and that info can be used behind the scenes as if the user specified every time he clicked a link. Does this make sense?
Alternatively, you could re-write the links so that they actually submit the form (no href attribute, just a onclick attribute going to some javascript function that submits the form with the representative info plus info of whichever link he chose).
You could also go for a pure javascript solution where selecting the rep changes the link, but that can be get pretty heavy into javascript, so maybe that wouldn't be the type of answer you are looking for.
Anyway, if any of these possibilities seems promising and you would like help getting them going, let me know.
Jared
| | Newbie | | Join Date: Oct 2008
Posts: 6
| | | re: Changing Links - VB - ASP.NET Quote:
Originally Posted by jhardman So if I select a representative, and then click a link you want the selection I made to be passed on to the server? I didn't dig really deep into your code, but it looks like you already submit the form as soon as the user makes a selection. If this is the case, all you have to do is add that info to the links: - <a href="site.com/somepage.asp?rep=<%=request("representative")%>">somepage.asp</a>
Does this make sense?
The next simplest solution would be to have the place the select drop down in an iframe - submit the form doesn't renew the whole page, but you could store the info on the server as a session variable, or on the browser as a cookie. The cookie or session variable is then available every time a script generates a page and that info can be used behind the scenes as if the user specified every time he clicked a link. Does this make sense?
Alternatively, you could re-write the links so that they actually submit the form (no href attribute, just a onclick attribute going to some javascript function that submits the form with the representative info plus info of whichever link he chose).
You could also go for a pure javascript solution where selecting the rep changes the link, but that can be get pretty heavy into javascript, so maybe that wouldn't be the type of answer you are looking for.
Anyway, if any of these possibilities seems promising and you would like help getting them going, let me know.
Jared Well I finished updating my site. All I did was manually put in the links. What I had in the jump menu was different reps. Each rep has their own ID and I wanted all the links in the page to change to their id so I didn't have to make 50 mirror pages which I did like an idiot.
So i need to create a database of the links and reps and then add that above code into all the links?
So for example i have the link http://www.trueessentials.net/index.asp?repid=4319298
I only need the #'s at the end to change in all the links when a representative is selected in the jump menu. So at the end of repid I would add =<%=request("representative")%> correct?
Thanks for the help. Sorry it took so long to respond i was trying to changing my contact form from php to ASP so my flash contact form works.
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | re: Changing Links - VB - ASP.NET Quote:
Originally Posted by IloveTacos Well I finished updating my site. All I did was manually put in the links. What I had in the jump menu was different reps. Each rep has their own ID and I wanted all the links in the page to change to their id so I didn't have to make 50 mirror pages which I did like an idiot.
So i need to create a database of the links and reps and then add that above code into all the links?
So for example i have the link http://www.trueessentials.net/index.asp?repid=4319298
I only need the #'s at the end to change in all the links when a representative is selected in the jump menu. So at the end of repid I would add =<%=request("representative")%> correct?
Thanks for the help. Sorry it took so long to respond i was trying to changing my contact form from php to ASP so my flash contact form works. Yes, I believe that is right, it's hard to tell for sure without seeing your code, but if it is set up like I think it is, that will work. or possibly <%=request("repid")%> - the request collection lists everything in cookies, forms and URL querystring. Anyway, try it and let me know if it goes well.
Jared
| | Newbie | | Join Date: Oct 2008
Posts: 6
| | | re: Changing Links - VB - ASP.NET Quote:
Originally Posted by jhardman Yes, I believe that is right, it's hard to tell for sure without seeing your code, but if it is set up like I think it is, that will work. or possibly <%=request("repid")%> - the request collection lists everything in cookies, forms and URL querystring. Anyway, try it and let me know if it goes well.
Jared Ok, so I created a database. I named it repid and it has two columns, Rep and ID. I used a drop down list.
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="repid"
DataTextField="Rep" DataValueField="ID">
</asp:DropDownList>
<asp:SqlDataSource ID="repid" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [Rep], [ID] FROM [repid]"></asp:SqlDataSource>
When they select a rep the value is equal to the id. I tried putting the request tag you suggested at the end of the link but I kept getting errors.
I'm trying to do it as a query string since that seems the easiest route.
So the url was http://xxx.asp?repid<%=request("id")%> which didn’t work. I kept getting the error, " server can’t contain <% %> constructs".
I’m using visual web developer 2008 and I set it to web form with VB and I unchecked place code in separate file. Any ideas on how to make it work?
|  | Moderator | | Join Date: May 2007 Location: United Kingdom
Posts: 395
| | | re: Changing Links - VB - ASP.NET
OK, now you're confusing the issue.
Your site is written in classic ASP, using the .asp file extension for each file, right?
Don't try and write more pages in Visual Web Developer, because they have the .aspx file extension (used with ASP.NET) and behave completely differently from how you're probably used to writing classic ASP.
My tip - stick to Notepad.
codegecko
| | Newbie | | Join Date: Oct 2008
Posts: 6
| | | re: Changing Links - VB - ASP.NET
No. They are all in aspx. I would stick to the notepad if I knew enough about ASP. You must of gotten the wrong idea. I don't know that much about ASP. I know I sound really smart and all, but I don't think programming ASP pages with notepad is the way to go at this point.
| | Newbie | | Join Date: Oct 2008
Posts: 6
| | | re: Changing Links - VB - ASP.NET
Here is the code I have right now:
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Response.Write(DropDownList1.SelectedValue)
End Sub
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedInde xChanged" DataSourceID="reps"
DataTextField="repid" DataValueField="id"></asp:DropDownList>
<asp:SqlDataSource ID="reps" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [repid], [id] FROM [reps]"></asp:SqlDataSource>
All the links look like this :http://www.madeup.net/index.asp?repid=id
The drop down menu changes and reloads the page, but it just puts the id at the top of the page and repreats it twice.
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | re: Changing Links - VB - ASP.NET Quote:
Originally Posted by IloveTacos No. They are all in aspx. I would stick to the notepad if I knew enough about ASP. You must of gotten the wrong idea. I don't know that much about ASP. I know I sound really smart and all, but I don't think programming ASP pages with notepad is the way to go at this point. That's the problem! No wonder our answers didn't help at all! You have asked your question in the ASP forum, but you are actually working with ASP.NET. ASP (file extension .asp) is not compatible with ASP.NET (file extension .aspx), hence the confusion.
I'll move your thread over to the correct forum, and they should be able to give you the correct solution.
Jared
|  | Similar .NET Framework bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,327 network members.
|