469,636 Members | 1,516 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,636 developers. It's quick & easy.

changing html links dynamically on page

Hello All, I am a newbie to web development, so please help me out with this issue.

html
---------

<form id="Form1" method="post" runat="server">
<asp:TextBox id="txtempid" style="Z-INDEX: 101; LEFT: 256px; POSITION: absolute; TOP: 160px"
runat="server" Width="184px"></asp:TextBox>
<asp:Label id="Label1" style="Z-INDEX: 102; LEFT: 32px; POSITION: absolute; TOP: 152px" runat="server"
Width="152px" Height="32px">Enter Empid</asp:Label>
<br>
<A id="empid" href="#">Details for employee '1234'</A>
<A id=empdet href=#>"Employee name is Scott Tiger"</A></td>
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 112px; POSITION: absolute; TOP: 240px" runat="server"
Text="Button"></asp:Button>
</form>

code-behind in c#
--------------

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Response.Write(txtempid.Text);
string mysql = "select empname from emp where empid = " + txtempid.text;
string empname;
//query db get empname
string myempid = "Details for employee " + txtempid.Text;
string myempdet = "Employee name is " + myempname;
//the above 2 lines need to be written to the browser in place of the two existing links
}




when the user enters a new empid as criteria, the criteria goes to the server, gets validated, details are obtained for the same and need to be displayed back on the page

Question - How do i change the text in the link to reflect the new values?
---------------------------------------------------------------------------------------------------------


Any help will be greatly appreciated

Thanks and regards
Nanda
Jan 12 '08 #1
2 921
kunal pawar
297 100+
Make your myempid and dept variable as public and echo them,
as show in following......

<form id="Form1" method="post" runat="server">
<asp:TextBox id="txtempid" style="Z-INDEX: 101; LEFT: 256px; POSITION: absolute; TOP: 160px"
runat="server" Width="184px"></asp:TextBox>
<asp:Label id="Label1" style="Z-INDEX: 102; LEFT: 32px; POSITION: absolute; TOP: 152px" runat="server"
Width="152px" Height="32px">Enter Empid</asp:Label>
<br>
<A id="empid" href="#"><%=myempid%></A>
<A id=empdet href=#><%=myempdet%></A></td>
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 112px; POSITION: absolute; TOP: 240px" runat="server"
Text="Button"></asp:Button>
</form>


code-behind in c#
--------------
// MAke your variables public
public string myempid,myempdet ;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Response.Write(txtempid.Text);
string mysql = "select empname from emp where empid = " + txtempid.text;
string empname;
//query db get empname
myempid = "Details for employee " + txtempid.Text;
myempdet = "Employee name is " + myempname;
//the above 2 lines need to be written to the browser in place of the two existing links
}




when the user enters a new empid as criteria, the criteria goes to the server, gets validated, details are obtained for the same and need to be displayed back on the page

Question - How do i change the text in the link to reflect the new values?
---------------------------------------------------------------------------------------------------------


Any help will be greatly appreciated

Thanks and regards
Nanda[/quote]
Jan 14 '08 #2
kunal pawar
297 100+
hi..
rather then use above classic asp method u can use server Hyperlink control and assign text from page behind code
Jan 14 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Kenny | last post: by
2 posts views Thread by wjbell | last post: by
3 posts views Thread by John Telford | last post: by
2 posts views Thread by Dominic Myers | last post: by
5 posts views Thread by Andrew Poulos | last post: by
2 posts views Thread by DartmanX | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.