Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Events
Message
From
11/10/2002 09:50:35
Jim Rieck
Quicken Loans/Rock Financial/Title Sourc
Livonia, Michigan, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Events
Miscellaneous
Thread ID:
00710281
Message ID:
00710281
Views:
49
All,

I am creating a custom search control that we are going to use for a web app. I created the logic to create the controls which works great. I am having a problem with the click event logic for a button on my control. The entire code for the control is below. Any help would be great!

Thanks

Jim

using System;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.ComponentModel;
using System.Web.UI;
using System.Web;

namespace SearchControl
{
///
/// Summary description for SearchControl.
///

///

[DefaultEvent("Click")]
public class SearchControl : System.Web.UI.WebControls.WebControl
{
#region "Properties and Events"
private string searchproc;
[Bindable(true),
Category("Data"),
DefaultValue("")]
public string SearchProcedure
{
get
{
this.EnsureChildControls();
return this.searchproc;
}
set
{
this.EnsureChildControls();
this.searchproc = value;
}
}

private string paramname;
[Bindable(true),
Category("Data"),
DefaultValue("")]
public string ParamName
{
get
{
this.EnsureChildControls();
return this.paramname;
}
set
{
this.EnsureChildControls();
this.paramname = value;
}
}
#endregion

#region "Define Controls"
Label lblSearch = new Label();
TextBox txtSearch = new TextBox();
Button cmdSearch = new Button();
RequiredFieldValidator rfldSearchText = new RequiredFieldValidator();
#endregion

#region "Events for custom control and child controls."
public SearchControl()
{
}
protected override void CreateChildControls()
{
this.Style["position"] = "Absolute";
// Set properties and add Search Label to custom control.
lblSearch.Style["position"] = "Absolute";
lblSearch.Text = "Search:";
lblSearch.Style["Left"] = "10px";
lblSearch.Style["Top"] = "10px";
lblSearch.Style["Width"] = "15px";
Controls.Add(lblSearch);
// Set properties and add Search textbox to custom control.
txtSearch.Style["position"] = "Absolute";
txtSearch.Text = "";
txtSearch.Style["Left"] = "60px";
txtSearch.Style["Width"] = "175px";
txtSearch.Style["Top"] = "10px";
txtSearch.ID="txtSearch";
Controls.Add(txtSearch);
// Set properties and add Search button to custom control.
cmdSearch.Style["position"] = "Absolute";
cmdSearch.Text = "Search";
cmdSearch.Style["Left"] = "235px";
cmdSearch.Style["Top"] = "10px";
cmdSearch.Style["Width"] = "65px";
cmdSearch.CausesValidation = false;
cmdSearch.Click += new EventHandler(cmdSearchClicked); Controls.Add(cmdSearch);
// Set properties and add requiredfield control to custom control.
rfldSearchText.Style["position"] = "Absolute";
rfldSearchText.Style["Left"] = "10px";
rfldSearchText.Style["top"] = "30px";
rfldSearchText.ErrorMessage = "Cannot Search - Please enter text in the search box.";
rfldSearchText.ControlToValidate="txtSearch";
Controls.Add(rfldSearchText);
}
public event EventHandler Click;
void cmdSearchClicked(object sender, EventArgs e)
{
this.Page.Response.Redirect("http://www.microsoft.com");

// Call the event method.
// OnClick(EventArgs.Empty);
}

protected virtual void OnClick(EventArgs e)
{
// Raise the event.
Click(this, e);
}

protected override void Render(System.Web.UI.HtmlTextWriter output)
{
base.Render(output);
}


#endregion
}// End Class


}//End Namspace
Thanks

Jim
Next
Reply
Map
View

Click here to load this message in the networking platform