kdeutsch
asked on
Create redirect link in code behind
I am trying to create a redirect link in my code behind. If the data row I am pulling end up blank I want it to put in the field "NOT SET' (DONE) if there is something I want it to list out what is in data rows (DONE). The next portion is I want to turn it into a redirect link so that if someone click on the words above it redirect them to another page to set some further values, below is my code but I cant seem to get it correct.
sql = "Select strBenchmarkName from tblBenchmarkname where intSid = " & myDataTable.Rows(0)(1) & " order by strBenchmarkname"
BmTable = New DataTable
BmTable = getData(sql)
If BmTable.Rows.Count = 0 Then
bmName = ""
Else
For Each bmrow In BmTable.Rows
bmName += bmrow(0) & ", "
Next
bmName = Left(bmName, Len(bmName) - 2)
End If
If isAdmin = True Then
If bmName = "" Then
bmName = "(not set)"
End If
lblBMName.Text = "<div style='display:inline;cursor:hand;' onclick='window.location.replace('EditMetric.aspx?sid=' + myDataTable.Rows(0)(1)&kpname=myDataTable.Rows(0)(1)); & bmName & "</div>"
Else
lblBMName.Text = "<div style='display:inline;cursor:hand;' onclick='window.location.replace('EditMetric.aspx?sid=' + myDataTable.Rows(0)(1)&kpname=myDataTable.Rows(0)(1)); & bmName & "</div>"
End If
Try just making your label an anchor tag like this:
lblBMName.Text = "<div style='display:inline;curs or:hand;> <A HREF='EditMetric.aspx?sid= '" & myDataTable.Rows(0)(1) & "kpname=" & myDataTable.Rows(0)(1) & bmName & "> Whatever text you want visible </a></div>"
lblBMName.Text = "<div style='display:inline;curs
ASKER
Ok got to this point but it will not recognize my second variable and the text of the data before it.
lblBMName.Text = "<a onclick='javascript:window .open(""Ed itMetric.a spx?sid=" & myDataTable.Rows(0)(1)&kpN ame=& myDataTable.Rows(0)(0)""", """", ""fullscreen=yes scrollbars=yes"");' " _
& "style='text-decoration:un derline;cu rsor:hand; + bmname'>"
Else
lblBMName.Text = bmName + "<a onclick='javascript:window .open(""Ed itMetric.a spx?sid=" & myDataTable.Rows(0)(1) &&kpName=& myDataTable.Rows(0)(0) """, """", ""fullscreen=yes scrollbars=yes"");' " _
& "style='text-decoration:un derline;cu rsor:hand; + bmname'>"
lblBMName.Text = "<a onclick='javascript:window
& "style='text-decoration:un
Else
lblBMName.Text = bmName + "<a onclick='javascript:window
& "style='text-decoration:un
ASKER
propakmike,
For some reason If I make a div tag it messes up my whole screen for some reason, need to change to a onclick event or a straight A href that redir4ects to another page automatically.
lblBMName.Text = "<a onclick='javascript:window .open(""Ed itMetric.a spx?sid=" & myDataTable.Rows(0)(1) & "kpName="& myDataTable.Rows(0)(0)"""" , """"", ""fullscreen=yes scrollbars=yes"");' " _
& "style='text-decoration:un derline;cu rsor:hand; + bmname'>"
For some reason If I make a div tag it messes up my whole screen for some reason, need to change to a onclick event or a straight A href that redir4ects to another page automatically.
lblBMName.Text = "<a onclick='javascript:window
& "style='text-decoration:un
You can place your div tag on your aspx designer page right before the label.
ASKER
propakmike:,
Sorry not a javascript guy or one whom uses divs alot, is there a way to make it a onclick event from the code behind that you can click on that text and pass the 2 variables to next page.
Sorry not a javascript guy or one whom uses divs alot, is there a way to make it a onclick event from the code behind that you can click on that text and pass the 2 variables to next page.
ASKER
This seems to be what I want to do but I need the second variable in here to work and then it opens in a wierd window I just need it to open in same window to new site.
lblBMName.Text = bmName + "<a onclick='javascript:window .open(""Ed itMetric.a spx?sid=" & myDataTable.Rows(0)(1) & "kpName=& myDataTable.Rows(0)(0) """", """", ""fullscreen=yes scrollbars=yes"");' " _
& "style='text-decoration:un derline;cu rsor:hand; + bmname'>"
lblBMName.Text = bmName + "<a onclick='javascript:window
& "style='text-decoration:un
You have set the bmName value inside the style property of hyperlink tag. Place it inner Text of hyperlink tag.
So in the last line, instead of
& "style='text-decoration:un derline;cu rsor:hand; + bmname'>"
change it as
& "style='text-decoration:un derline;cu rsor:hand; ' > & bmname & "</a>"
So in the last line, instead of
& "style='text-decoration:un
change it as
& "style='text-decoration:un
Change the text to have the Ampersands in the link.
EditMetric.aspx?sid=" & myDataTable.Rows(0)(1) & "&kpName="& myDataTable.Rows(0)(0)
EditMetric.aspx?sid=" & myDataTable.Rows(0)(1) & "&kpName="& myDataTable.Rows(0)(0)
ASKER
All,
Ok its worksing with passing the correct data, but still cant get the right text in there and it opens in a really goofy window with no resizable tools, is there a way to use a redirect with this method.
lblBMName.Text = "<a onclick='javascript:window .open(""Ed itMetric.a spx?sid=" & myDataTable.Rows(0)(1) & "&kpName=" & myDataTable.Rows(0)(0) & """, """", ""fullscreen=yes scrollbars=yes"");' " _
& "style='text-decoration:un derline;cu rsor:hand; '> & bmname & "
name in text box cmoes up with &bmname & instead of what should be Not Set or what was in the label from data row per code above.
Ok its worksing with passing the correct data, but still cant get the right text in there and it opens in a really goofy window with no resizable tools, is there a way to use a redirect with this method.
lblBMName.Text = "<a onclick='javascript:window
& "style='text-decoration:un
name in text box cmoes up with &bmname & instead of what should be Not Set or what was in the label from data row per code above.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I get an error that says end of statement expected.
lblBMName.Text = bmName + "<a HREF="EditMetric.aspx?sid= " & myDataTable.Rows(0)(1) & "&kpName=" & myDataTable.Rows(0)(0) & """, """", ""fullscreen=yes scrollbars=yes"");' " _
& "style='text-decoration:un derline;cu rsor:hand; ' target='_new'>"
lblBMName.Text = bmName + "<a HREF="EditMetric.aspx?sid=
& "style='text-decoration:un
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
propakmike:,
Sorry for being a pain.
Ok, getting closer this is how the link works in the browser, how do i drop off the style out of it. and the text looks like this test1, tst2, test3_ the only part that is a onclikc is the underscore, cannot pick on rest of text.
http://localhost:1336/StratPlan/EditMetric.aspx?sid=9124&kpName=15style=
lblBMName.Text = bmName + "<a HREF='EditMetric.aspx?sid= " & myDataTable.Rows(0)(1) & "&kpName=" & pNum & "style='text-decoration:un derline;cu rsor:hand; ' target='_new'>"
Sorry for being a pain.
Ok, getting closer this is how the link works in the browser, how do i drop off the style out of it. and the text looks like this test1, tst2, test3_ the only part that is a onclikc is the underscore, cannot pick on rest of text.
http://localhost:1336/StratPlan/EditMetric.aspx?sid=9124&kpName=15style=
lblBMName.Text = bmName + "<a HREF='EditMetric.aspx?sid=
lblBMName.Text = "<a HREF='EditMetric.aspx?sid= " & myDataTable.Rows(0)(1) & "&kpName=" & pNum target='_new'>" & bmName & "</a>"
ASKER
propakmike:
I get an end of statement expected and a blue underline for everything after the PNum.
target='_new'>" & bmName & "</a>"
I get an end of statement expected and a blue underline for everything after the PNum.
target='_new'>" & bmName & "</a>"
ASKER
propakmike:
ok I did this and it took care of the name problem and the name is now a link, but the loiink still passes with like this. I just need up to the 15 part.
http://localhost:1336/StratPlan/EditMetric.aspx?sid=9124&kpName=15target=
I put in a & but then that put the style back in the query string.
lblBMName.Text = "<a HREF='EditMetric.aspx?sid= " & myDataTable.Rows(0)(1) & "&kpName=" & pNum & "target='_new'>" & bmName & "</a>"
ok I did this and it took care of the name problem and the name is now a link, but the loiink still passes with like this. I just need up to the 15 part.
http://localhost:1336/StratPlan/EditMetric.aspx?sid=9124&kpName=15target=
I put in a & but then that put the style back in the query string.
lblBMName.Text = "<a HREF='EditMetric.aspx?sid=
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
karthitron:
thanks it worked and opend in a redirected full window.
thanks it worked and opend in a redirected full window.
ASKER
Thanks for patience, and lots of help.
ASKER
Open in new window