S Nash
S Nash

Reputation: 2499

Add Div as a parameter to a function

I have a ASP.NET C# code.

I have some div elements with I set runat="Server" and they have ID's

I need to know how to pass these as parameters to a function.

So

public void A(type Div1) { }

In above what type Div 1 is?

Upvotes: 0

Views: 928

Answers (2)

Mike Marshall
Mike Marshall

Reputation: 7850

ASP.NET should create page variables of type HtmlGenericControl for each ID that you declare. For example, if your ID was Div1 then you could do the following:

string myText = Div1.InnerText;

Upvotes: 0

JonH
JonH

Reputation: 33153

Div's are very generic in fact they are HtmlGenericControl("div"). You can simply make them Panels and pass them in asp.net as Panel.

Try it out, create an <asp:Panel id="myPanel" runat="server" /> and run your html, look at its source. The panel translates to a div in the markup.

Upvotes: 1

Related Questions