views:

140

answers:

2

Hi I have a page with a Textbox, a Button and a Label control. On Button_Click event , I store the value of Textbox in a variable called S using code behind.

I want to show the value of S in the Lable control using inline code but not using the code behind. ?

Thanks in Advance

A: 

I am not exactly sure about the requirement, following with some modification will work. Embed this block to you aspx page

if using C#

<script runat="server">
   void Page_Load(Object sender, EventArgs e)
     {
        mylabel.Text = s; // replace with your label control
     }            
</script>

if using VB

<script runat="server">
    Sub Page_Load(Sender As Object, E As EventArgs)
    mylabel.Text = s
    End Sub
</script>
Asad Butt
+3  A: 

This is not the ASP.net approach, but you can add S as a member of the code-behind class (at least protected)

protected string S { get; private set; }

and retrieve it inline in the page markup with

<%= S %>

Wikser