Calling function or value from server side to html aspx

On my aspx, I have a client control which needs to receive a value from server side.

<tr>
    <td >
        <a class="lnk_abrepopup"
           title="MyPage.aspx?Cod_OP=<%# Return_CodOP() %>">
        </a>
    </td>
</tr>

Open in new window

Property title should receive a value. I call function Return_CodOP() which is declared in server side code behind like this:

<WebMethod(EnableSession:=True)>
Protected Function Return_CodOP() As String
        Return _Cod_OP
        '' Even if I put like Return "4", it gives nothing when it's called from html aspx
End Function

Open in new window

The thing is that in html aspx, function Return_OP() returns nothing. Maybe because there is no postback.

Is there any way to resolve this thing or some work around?
LVL 1
miyahiraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Russ SuterCommented:
Why not just use a server-side control? You can accomplish the same result on the server using a Response.Redirect command.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
miyahiraAuthor Commented:
Thanks! It works:

<tr>
    <td >
        <a id="LinkA" class="lnk_abrepopup" runat="server" >
        </a>
    </td>
</tr>

Open in new window



Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

          LinkA.Title = "MyPage.aspx?Cod_OP=" + _Cod_OP
End Sub

Open in new window

0
Russ SuterCommented:
You might just want to add code to check if you're responding to a postback event.

 If Page.IsPostback Then
   -- do stuff in here
 Endif

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.