ASP.NET - want to add href value to anchor in aspx page from a code behind strin

Asked By praveen madhogaria
06-Sep-10 04:15 AM

Hi All,

I am using a anchor tag in my aspx page.now in this href value i want to add the url and display value from a string which is present at my code-behind.

test.aspx.cs
string sLink=http://test.com/layouts/scan.aspx;


test.aspx

<a id="A1" href='<%=sLink %>' runat="server"><%=sLink%></a>

  harsh shah replied to praveen madhogaria
06-Sep-10 04:32 AM
Hi,

no need to bind a string value.
simply make a anchor tag in to server control and then u have get directly anchor control in a .cs file.
in a cs file give a url name in a href property.

i have given a below code.

test.aspx
<a id="A1"  runat="server"></a>


test.aspx.cs
string sLink=http://test.com/layouts/scan.aspx;
A1.href=sLink;
A1.InnerText =sLink;

Let me know

Regards,

Harsh Shah
  Anand Malli replied to praveen madhogaria
06-Sep-10 04:35 AM
Hi All,

you can access this anchor tag over there in your code behind and set its href over there only,i do not find any difficulty in this..its simple like below code,yeah the variable must have to public to be accessible in your mark up,there are two option make the string public or do like following

A1.href=sLink;

let me know if anything is there
thxs


  praveen madhogaria replied to harsh shah
06-Sep-10 05:50 AM

Thanks Harsh, this was exactly what i was looking for.

Thanks a lot.
  praveen madhogaria replied to Anand Malli
06-Sep-10 05:50 AM

Thanks Daivagna for your quick reply.
Create New Account
help
1: Assume that i am reading XmlNodeType.Text and I would like to know its tag node name. How do you do that without moving cursor up or down? Also How can I know parent tag of current node tag? Question 2: Assume that I am reading xml file and I would like to start at particular node tag. How can do that? Question 3: if you have xsd file, is there easy way Console .Write(reader.Name); } else if (reader.NodeType = = XmlNodeType .Text) { Console .Write( " / " +reader.Name+ " / " + reader.Value+ " / " ); } else { if (reader.NodeType = = XmlNodeType .EndElement) { Console .WriteLine(reader.Name); Console .ReadLine(); } } } reader.Close(); } Please time-layout> - <parameters applicable-location = "point1"> - <temperature type = "hourly" time-layout = "k-p1h-n1-0"> <value> 75< / value> <value> 76< / value> <value> 76< / value> <value> 79< / value> <value> 79< / value> <value> 78< / value> <value
Event error I just put some code in a cell value changed event of a grid view and im getting this message An unhandled exception of type 'System.StackOverflowException' occurred in WindowsApplication.exe this Cannot obtain value of local or argument '<this> ' as it is not available at this instruction pointer, possibly referencing the public field of a property instead of the private field to set a value, but there are many other causes. If you take the time to post sample code dataGridView1.Rows.Add(34); this.dataGridView2.Rows.Add(35); this.dataGridView2.Rows[0].Cells[2].Value = Gasto.Gastomedio1; this.dataGridView2.Rows[1].Cells[2].Value = Lodos.Recirculacion1; this.dataGridView2.Rows[2].Cells[2].Value = this.dataGridView1.Rows[0].Cells[24].Value; this.dataGridView2.Rows[3].Cells[2 Value = Parametros.DBO1; this.dataGridView2.Rows[5].Cells[2].Value = Parametros.DBOsoluble1; this.dataGridView2.Rows[7
Here is the Sample XML file <?xml version = "1.0" encoding = "utf-8"?> < params > < param > < value > < struct > < member > < name > result_count< / name > < value > < int > 1< / int > < / value > < / member > < member > < name > next_offset< / name > < value > < int > 1< / int > < / value > < / member > < member > < name > field_list< / name > < value > < array > < data > < value > < struct > < member > < name > name< / name value > < string > id< / string > < / value > < / member > < member > < name > type< / name > < value > < string > id< / string > < / value > < / member
Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B run? (B) What is reflection? (A) What are different types of JIT? (B) What are Value types and Reference types? (B) What is concept of Boxing and Unboxing ? (B) What is A) What is scavenging? (B) What are different types of caching using cache object of ASP.NET? (B) How can you cache different version of same page using ASP.NET cache object? (A) How will implement Page Fragment Caching? (B) Can you compare ASP.NET sessions with classic ASP? (B) Which are the various modes of storing ASP.NET
to 15 in a dataset of 100 records? Write code. Answer1 DataSet ds1 = new DataSet(); String strCon = ”data source = IBM-6BC8A0DACEF;initial catalog = pubs;integrated security = SSPI;persist” +” security info = False;user id = sa;workstation id = IBM-6BC8A0DACEF;packet size = 4096?; String strCom1 = ”SELECT * FROM employee”; SqlDataAdapter sqlDa1 = new SqlDataAdapter(strCom1, strCon); ds1.Tables.Add(”employee”); sqlDa1 Stored Procedure in.NET? Give an example. Answer1 ds1 = new DataSet(); sqlCon1 = new SqlConnection(connectionstring); String strCom1 = ”byroyalty”; sqlCom1 = new SqlCommand(strCom1, sqlCon1); sqlCom1.CommandType = CommandType.StoredProcedure; sqlDa1 = new SqlDataAdapter(sqlCom1); SqlParameter myPar = new SqlParameter(”@percentage”, SqlDbType.Int); sqlCom1.Parameters.Add (myPar); myPar.Value = 40; sqlDa1.Fill(ds1); dg1.DataSource = ds1; dg1.DataBind(); Answer2 Yes Dim cn as new maximum length of a varchar in SQL Server? Answer1 VARCHAR[(n)] Null-terminated Unicode character string of length n, with a maximum of 255 characters. If n is not supplied, then in Sql server as var_name int How do you separate business logic while creating an ASP.NET application? There are two level of asp.net debugging 1. Page level debugging For this we have to edit the page level