开发者

Return value from .aspx to .aspx.cs

开发者 https://www.devze.com 2023-03-15 01:22 出处:网络
I\'m passing the value of a variable in my.aspx.cs file to my .aspx file. When its in the aspx, the value of it gets changed and then needs to be returned back to the .aspx.cs file. However, it won\'t

I'm passing the value of a variable in my.aspx.cs file to my .aspx file. When its in the aspx, the value of it gets changed and then needs to be returned back to the .aspx.cs file. However, it won't let me change the value of the variable. Any suggestions?

.cs

       private string dateLookup;
    public string DateLookup
    {
        get { return dateLookup; }
        set { dateLookup = value; }
    }

.aspx

    <script runat="server">
    void Selection_Change(Objec开发者_开发问答t sender, EventArgs e)
    {
       "<%=DateLookup %>" = monthList.SelectedItem.Value;
    }

</script>


You can assign the property like any other property:

DateLookup = something;

The <%= ... %> syntax is used to print any value on to the page.


the event should also be in your code behind (cs)

void Selection_Change(Object sender, EventArgs e)
{
    DateLookup = monthList.SelectedItem.Value;
} 

the <%=DateLookup %> notation does not assign something, it outputs it to the html

0

精彩评论

暂无评论...
验证码 换一张
取 消