Extending DropDownList's Methods (trying to put javascript code to parent page of the control on certain methods)

Hi,

 Now i am creating a dropdown list that can filter and search keywords inside while typing on it. Normally, .net DropdownList doesn't supports that kind of features like windows' combo box. For that reason, I extended the dropdownlist class and tried to put that javascript code inside the databind() method, by overriding it. Unfortunately, it is unsuccessful and I thought that the way I am doing have some problems. So i would like to ask for a help from any one of you. 

 What I tried to do is to put the javascript inside dropdownlist's parent page while dropdownlist databind() or render() is called.

 Please help me. Followings are my code for your better understanding. Thank you very much indeed.

 

public override void DataBind()
        {
            base.DataBind();

            Panel _pn = new Panel();
            _pn.Width = new Unit("3px");
            this.Parent.Controls.Add(_pn);

            string script = "<script type=\"text/javascript\">\n var z=dhtmlXComboFromSelect(\"" + this.ClientID + "\");z.enableFilteringMode(true);\n z.attachEvent(\"onBlur\",onBlurValidate);\n" +
                "function onBlurValidate()\n{" +
                "var selText = z.getSelectedText();\n\n" +
                "if(selText == \"\")\n" +
                "{z.setComboText(\"\");}" +
                "}\n" +
                "</script>";

            HtmlGenericControl Include = new HtmlGenericControl();
            Include.InnerHtml = script;
            _pn.Controls.Add(Include);
           

        }

 

 

0
alex_kent_18
8/23/2008 5:37:35 AM
asp.net.custom-server-controls 3498 articles. 0 followers. Follow

1 Replies
608 Views

Similar Articles

[PageSpeed] 7

Your code should work in a textbox.  On the DropDownList, you have to add (items)

.Item,Add(New ListItem("Name", "Value")

.Item.Remove(Some Syntax)

Perhaps just renaming the item via javascript will work, but I don't know how

Wait, perhaps changing the selected index based on text input could work 

0
jkirkerx
8/23/2008 6:44:05 PM
Reply:

Similar Artilces:

Can I have a web user control call a method on the page it's parent page?
I'm building an application where I'm using serveral different controls on a page and as one of them causes a postback I may want the page to make changes to other controls.  Is there a way to either fire and event off from the control that the page could then capture or simply have the control call a method of it's parent page? Obviously the Page object is there to work with, but I can't seem to figure out how to specifically cast it as a specific page.  For real man, In your user control you need to create a public event which is raised by the event of the...

How to put Response.Write("<script language='javascript' type='text/javascript'>") into custom server control
Hello, In my Page_Load I have the following code: =====  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Response.Write("<script language='javascript' type='text/javascript'>" & vbCrLf) Response.Write("Function();") Response.Write("</script>") End Sub =====  Because I want to re-use this on every webpage, I want to build a custom server control. How can I implement this?Johan TheunissenMCPD, MCSE, MCTS BizTalk 2006==============================Please mark the most helpful reply/replies as "Answer". ...

Controls accessing methods of it's parent page
Hi All,I've just tried upgrading a VB/ASP.NET 2003 project to VB/ASP.NET 2005 and I have heaps of errors.  One specific one I wanted to narrow down on was when a user control is placed on a web form.  Say for example the webform has a public function on it and that in the PageLoad of the ascx, the control wants to access the function that is on the page it sits on.  In order to do this in the existing framework/vs I used something like: _Groups = CType(Me.Page, CommissionsPage).GetGroups()where CommissionsPage is the WebForm.Now when I do this in VB.NET VS 2005 i get the erro...

Label control's text doesn't appear to be set (in the page which has a user control )when trying to update the text property in the FormView's ItemUpdated event
Hi There,I have a user control which hosts a formview control, gridview control and a label control. The grid view is usedto show rows in the DB and when clicked to edit each row, a form view opens up in edit mode with that particular row info. So I have nothing in the item template.My first question is..is it mandatory to have smth in the itemtemplate of the form view.I have controls in edititemtemplate and insertitemtemplate.When a particular row is edited, I would like to show a status msg showing that the row has been updated.For this, I use the ItemUpdated event of the formview and try ...

Accessing contnet page's control in the Javascript code of master page
Hello  I have one master page in which i put javascript code, CSS and one Content place Holder. In my content page i add two control one for Login and another for pass word and one Custom validator control. Now i want to call the Javascript code which is written in Master page as the Clinet function in my Custom Validator control to run to validate the value entered in the login and password(TextBox) control. How i do this. My content page having Server side script that i want to call to validate page at the server side. For submitting the page i use Button control and in its PostB...

Access parent page's controls from a user control
I have a .ascx user control that contains a button. I place this user control on a .aspx web page. The web page contains a textbox. When I click on the button in the user control I want the data in the textbox (in the web page) to be saved to the database. I want to write this code in the click event of the user control's button. Is there any way I can access the parent web page's controls from the user control? Add event to user control which fires on page when button inside user control is clicked. view post 779045Jigar Desai-----------------------Do not forget to "Mark as Answer...

Calling a method from a control page on the axpx page where the control page exists.
Hello,  I have an .aspx page that has a method called grdMain_DataBind().  I have a control page that loads within the aspx page which has its own logic.  I have a button on my control page called "SAVE".  How can I call the method grdMain_DataBind thats in my aspx logic from the control that exists on that page when I click SAVE button.  Is there a way? If I were you, I'd simply create a "Save" Event within your control. When the Button in your control is pressed, in the Click handler for that Button you can raise the event. Then, within t...

How to access all the methods of server controls and infragistics controls from client-side javascript.
I have some web controls on my page, which i want to manipulate without going to the server, that is, from a client-side javascript. I know how to call them with the documents.forms.... but i do not know how to call their methods. For the text box, the method to manipulate it is 'value'. It's a property i think. for the html <select> it is the 'options' array. But for the others, I dont know.My question is the following:I have an infragistics control: the UltraWebTree.This is its code in html: <ignav:ultrawebtree id="UltraWebTree1" style="Z-INDEX: 108; LEFT: 352p...

Can I hide a user control's control from the hosting page's client script?
Okay, my previous question was not unswered and I guess you can't hide a control's panel with server code then show it with client code. Now this is what I try to do: on the hosting page's onload event, call a function to hide the user control's penal. Here is the deal: the user control was looped as many times as data required. So the penals will be name mypanel1, my panel2, etc... that is not even a problem if I know if the following is true: * Do all server codes finish running before the page get sent back to the client? Say the database gave me 5 penals, I can then determine how...

Setting a parent page's label control text from a user control
I have a .net 2.0 site where I'll have the same form for user input on a number of pages. I plan on using a user control for this. The catch is if the user doesn't input the data properly I want to write the error message to a label control on the parent page, not in the user control. This is because the design for each parent page is different enough that we need to display the error message in a different part of the page. I've seen a couple of websites that mention using a base page that all my pages could inherit from to have a user control interact with the parent page. This...

Problem finding Server control's child controls by Page.FindControl
Hello all, I am unable to find my Web Custom Control's child controls by using Page.FindControl on my WebForm. I have a web custom control which has a label and a text as its child controls Now On my WebForm the code is - SampleControl.SimpleControl SC = (SampleControl.SimpleControl) Page.FindControl(SimpleControl1.ID) TextBox tb = (TextBox) SC.FindControl(SimpleControl1.ID + "_myTb");   where, SimpleControl1 is an object of type my custom control SimpleControl i get an error, 'tb' shows as undefined_value Do help me if u can. Regards, Sanchita...

when i load control dynamically i cannot get server control's clientid in javascript
i load control dynamically from codebehind, in one placeholder,i put javascript  validations for pages,but i cannot get servercontrol's clientid in javascript function, also when i see the "view source" of page, i cannot find those servercontrols which load dynamically, is there any solution to do this??thanks VISHAL PAREKH  When you load your control, please add an ID on it ex:TextBox txt = new TextBox();txt.ID = "MyID";Then on your script you can point to this txt.ClientIDHope this helpCheersAndyRemember to mark this as answered if this solved ...

Calling user control's method from master page???
I have a user control in a master page, when i try to access the controls method from master page  i get Object reference not set to an instance of an object. What am i doing wrong? please help. Many thanks in advance. .. codes for user control and master page is shown below. -- User Control public partial class UC_uc : System.Web.UI.UserControl{public string Name{get { return txtName.Text; }set { txtName.Text = value; }} public event EventHandler OnSearch;protected void Page_Load(object sender, EventArgs e){} public void btnSearch_Click(object sender, EventArgs e){OnSea...

calling a master page's method from user control
Hey all, I have a user control on an aspx page which has a master page. That master page has a method, which I need to call from the user control's button click event. How can i access master page's method from a user control which is used on an aspx page? Thanks,Ujjaval  One way of doing this is as follows: 1. Define an interface in your App_Code folder, and on this interface define the methods that you want to expose from the Master Page.2. Have the Master Page implement the interface.3. In the user control, you can then access the Page.Master property. Cast thi...

Web resources about - Extending DropDownList's Methods (trying to put javascript code to parent page of the control on certain methods) - asp.net.custom-server-controls

Resources last updated: 12/17/2015 3:20:11 PM