Reputation: 426
I have an aspx user control which i use in two different pages. I have a "save" button in usercontrol page and when it gets clicked it has to store data in db. But the data is to be stored in different tables based on the page. The question is how to make the save button event of the user control to behave differently based on the pages that using the usercontrol. And also the heading and some css classes must be different for different pages. How to check for the css classes also for different pages.
Upvotes: 0
Views: 243
Reputation: 1
Thanks that works!!
Public Property FunctionPerpose() As String
Get
Return m_FunctionPerpose
End Get
Set(value As String)
m_FunctionPerpose = value
End Set
End Property
Private m_FunctionPerpose As String
Private Sub btnUpload_Click(sender As Object, e As EventArgs) Handles btnUpload.Click
If FunctionPerpose = "PurificationImport" Then
MessageBox.Show("File uploaded successfully")
ElseIf FunctionPerpose = "XYZImport" Then
end if end sub
build this user control and you can see this new FunctionPerpose property in properties window at right side where you are using that user control
Upvotes: -1
Reputation: 225
It's possible to define property TableName in UserControl class:
public string TableName { get; set; }
set it where the control is used:
<uc:MyControl runat="Server" ID="MyControl1" TableName="Foo" />
<uc:MyControl runat="Server" ID="MyControl2" TableName="Bar" />
and use it in the event handler as any other .NET property:
protected void Save_Clicked(object sender, EventArgs e)
{
string tableName = TableName;
}
Upvotes: 3