Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4001176
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:52:21+00:00 2026-05-20T07:52:21+00:00

i try to write my own control.But my control’ html has problem: Look like

  • 0

i try to write my own control.But my control’ html has problem: Look like

enter image description here

My Search button look above. But i need below: how can i do that?

enter image description here


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls.WebParts; // Ekle
using System.Web.UI.WebControls; // Ekle
using System.Web.UI;
using System.Collections;
using System.Threading;

namespace MyFilterControl
{

    public class FilterControl : WebPart
    {
        internal List<Content> list { get; set; }
        public Button BtnSearch { get; set; }
        public event EventHandler Click;
        public string FilterButtonText { get; set; }
        public String PhID { get; set; }
        internal PlaceHolder PlhControl { get; set; }
        private string controlWidth = "10";
        public FilterControl()
        {

            list = new List<Content>();
            BtnSearch = new Button();
            PlhControl = new PlaceHolder();
            PlhControl.ID = Guid.NewGuid().ToString();
            if (string.IsNullOrEmpty(PhID))
            {
                BtnSearch.ID = "btnSearch";
            }
            else
                BtnSearch.ID = PhID;
            if (string.IsNullOrEmpty(FilterButtonText))
            {
                 BtnSearch.Text = "Search";
            }
            else
                BtnSearch.Text = FilterButtonText;
            BtnSearch.Click += new EventHandler(BtnSearch_Click);
        }
        private Table mainTable = new Table();
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            TableRow tblRow = new TableRow();
            TableCell tblCell1 = new TableCell();

            PlhControl.Controls.Add(new LiteralControl("<table><tr>"));
            tblCell1.Controls.Add(PlhControl);
            TableCell tblCell2 = new TableCell();
            tblCell2.Controls.Add(BtnSearch);
            tblRow.Cells.Add(tblCell1);
            tblRow.Cells.Add(tblCell2);
            mainTable.Rows.Add(tblRow);
            this.Controls.Add(mainTable);
        }
        void BtnSearch_Click(object sender, EventArgs e)
        {
            PlhControl.Controls.Add(new LiteralControl("</tr><table>"));

            foreach (var item in PlhControl.Controls)
            {
                if (item is MyTextBoxControl)
                {
                    MyTextBoxControl t1 = (MyTextBoxControl)item;
                    if (t1.Text != "")
                    {
                        Add(new Content() { FieldName = t1.ID, Data = t1.Text, ID = Guid.NewGuid().ToString(), dataType = t1.dataType, filter=t1.filter });
                    }
                }
            }
            Click(this, e);

        }

        public string Query()
        {
            string Qry = String.Empty;
            int i = 0;
            foreach (var item in list)
            {
                switch (item.filter)
                {
                    case Filter.BeginsWith: Qry += String.Format(item.FieldName.ToString() + ".StartsWith({0}) && ", "@" + i.ToString());
                        break;
                    case Filter.EndsWith: Qry += String.Format(item.FieldName.ToString() + ".EndsWith({0}) && ", "@" + i.ToString());
                        break;
                    case Filter.Contains: Qry += String.Format(item.FieldName.ToString() + ".Contains({0}) && ", "@"+i.ToString());
                        break;
                    case Filter.Default: Qry += String.Format("{0}=={1} && ", item.FieldName, "@" + i.ToString());
                        break;
                    default:
                        break;
                }

                i++;
            }
            Qry = Qry.TrimEnd('&', '&', ' ');
            return Qry;
        }

        public object[] QueryParams()
        {
            ArrayList arrList = new ArrayList();
            foreach (var item in list)
            {
                if (item.dataType == DataType.String) 
                arrList.Add(item.Data);
                else if (item.dataType == DataType.Int32)
                {
                    int intVal = Convert.ToInt32(item.Data);
                    arrList.Add(intVal);
                }
            }
            object[] strArray = arrList.ToArray(typeof(object)) as object[];
            return strArray;
        }

        public string id { get; set; }
        public void AddItem(ContentItem content)
        {
            PlhControl.Controls.Add(new LiteralControl("<td  style=\"text-align:left\">"));
            PlhControl.Controls.Add(new Label() { ID = Guid.NewGuid().ToString(), Text = content.LabelName });
            PlhControl.Controls.Add(new LiteralControl(":</td>"));
            PlhControl.Controls.Add(new LiteralControl("<td  style=\"text-align:left\">"));
            PlhControl.Controls.Add(new MyTextBoxControl() { ID = content.FieldName, dataType = content.dataType, filter = content.filter });
            PlhControl.Controls.Add(new LiteralControl("</td>"));
        }
        private void Add(Content content)
        {
            list.Add(new Content() { ID = content.ID, Data = content.Data, FieldName = content.FieldName, dataType=content.dataType, filter= content.filter });
        }
    }

    internal class Content
    {
        internal string ID { get; set; }
        public string Data { get; set; }
        public string FieldName { get; set; }
        public DataType dataType { get; set; }
        public Filter filter { get; set; }
    }

    public class ContentItem
    {
        private string ID { get; set; }
        public string LabelName { get; set; }
        public string FieldName { get; set; }
        public DataType dataType { get; set; }
        public Filter filter { get; set; }
    }

    public class MyTextBoxControl : TextBox
    {
        public DataType dataType { get; set; }
        public Filter filter { get; set; }
    }

    public enum DataType
    {
        String,Int32
    }

    public enum Filter
    {
        BeginsWith,EndsWith,Contains,Default
    }
}


  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:52:22+00:00Added an answer on May 20, 2026 at 7:52 am

    You can place each control in a table cell. Or you can place everything in a div with a fixed heigh.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For my very own little parser framework, I am trying to define (something like)
I have a script execution engine in which the end users write scripts to
I would like to know how, in Objective-C, how to tell if a string
I'm trying to write a PowerShell script that will do the following: Executes a
I am thinking of learning a CMS. I am not sure which one will
INITIAL NOTE: This is just for a personal tinkering project; I'm not writing enterprise
So I have two tables in this simplified example: People and Houses. People can
I have seen System.Transactions namespace, and wondered, can I actually make a RDMBS with
I'm working on a EMF project where I've created a ecore model from a
I've written a class that implements IEnumerable<T> . I have a method that returns

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.