0

How can I make an object reference of a Literal that I have declared in the aspx page. Now I use it as ltlContents.Text = ..... but I need to make a reference of that ltlContents so I can use it in a static method the same way I use it with its .Text attribute.

I tried something like Literal ltl = ... but this is new for me, as it's different from the usual object referencing, as it comes from the front-end.

UPDATE: I want to use the ltlContents object in a static method like this: ltlContents.Text = valueFromSomeFunction, but the compiler gives me the following error: An object reference is required for the non-static field, method, or property _Default.ltlContents.

4

2 に答える 2

0

リクエストごとに、ページの新しいオブジェクトがレスポンス(html)として提供されるためです。したがって、それを行うことはできません。それを関数
に使用する代わりに、関数は関数から値を返し、それを使用します。literalまたは、リテラルの値を使用して機能します。

于 2013-09-04T11:23:52.667 に答える