MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Hoow to Customize an INPUTBOX (Textbox)  (Mono Support )

Viewed 18831 time(s), 9 post(s) 9/18/2012 10:00:31 AMby Clipflair1
Clipflair1

Clipflair1

9/18/2012 10:05:56 AM
Hello,

I am working on the Login section, editing the LoginModule.ascx. What I want to do is edit the text box fields so that they will display the title (e.g username / password label) on them as a watermark.

I need to apply the code in the <input ... > form element area but I don't know where to access it from.
The code of the module I am working on is: <asp:TextBox ID="UserName" runat="server"></asp:TextBox> and I know that this code calls for the required elements.

Di you Know where I could find them?

Thank you in Advance,
Panayiotis
This content has not been rated yet. 
159 Reputation 18 Total posts
GeorgeBirbilis4

GeorgeBirbilis4

9/18/2012 11:41:29 AM
since it says runat="server", there is backend code at the server-side (running at page postback) that expects that control to be an ASP.net TextBox (or it can also be a descendent class I believe)

so you need a watermark TextBox control, Microsoft already has one at their AJAX toolkit:
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/TextBoxWatermark/TextBoxWatermark.aspx

even better it says there: "TextBoxWatermark is an ASP.NET AJAX extender that can be attached to an ASP.NET TextBox control to get "watermark" behavior" which means it's not a subclass, but can apply it on the existing TextBox to change its behaviour. I hope it works with classic ASP.net WebForms too
This content has not been rated yet. 
35 Reputation 6 Total posts
denis

denis

9/18/2012 12:54:07 PM
I am not sure that I understood what you want, but my best guess is that you want to apply some javascript/jQuery functionality to the username and pwd textboxes. In that case, username tetbox renderes to the input field with the ID "ctl00_ctl00_ctl01_ctl00_cp_cp_cp_cp_ctlLogin_ctlLogin_UserName" in the default package. You can use this ID, or alternatively (this would be the more robust solution) apply a CSS class to it (in the LoginModule.ascx) so you could access it on the client side.
This content has not been rated yet. 
7207 Reputation 956 Total posts
denis

denis

9/18/2012 1:11:33 PM

Sorry, I didn't see your second post. I would recommend you to use more lightweight jQuery packages for such purposes. For example, we are using the watermark functionality in the WallNotes module, you just need to register the same script

JavascriptUtility.RegisterClientScriptInclude(this.Page, Paths.MonoX.Scripts.jquery_watermarktext_js);

In our case, each input element with the CSS class "jq_swap_value". All you have to do is to check if the textbox is empty in the PreRender event and assign the watermark value to that field:

if (String.IsNullOrEmpty(txtInput.Text))
    txtInput.Text = SocialNetworkingResources.WallNotes_WatermarkText;



This content has not been rated yet. 
7207 Reputation 956 Total posts
GeorgeBirbilis5

GeorgeBirbilis5

9/18/2012 2:07:51 PM
The thing is that Panos (our designer) and me included would prefer not having to write codebehind for that (or place similar commands inside the page). So the AJAX toolkit's TextBox extender seems to be a better match, since from what I understand it applies the watermark value when needed only and you define it in the markup

One issue may be whether that control existed at the older version of AJAX Control Toolkit included in MonoX, else one will need to tell ASP.net to use the newer version (installed from http://ajaxcontroltoolkit.codeplex.com/releases/view/90063), editing web.config as explained at:
http://www.mono-software.com/Mono/Pages/Discussion/dtopic/tMKlkb6dcUWfI6CnANPaxg/AJAX-Control-Toolkit/?username=mzilic

they'd need to add after the <%@ Page ...> the declaration:
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
(supposing the master page doesn't already have such a thing)

and then in the main part of the page/control:
<ajax:ToolkitScriptManager runat="Server" />
once

and then above
<asp:TextBox runat="server" ID="Password" TextMode="Password"></asp:TextBox>
place
<ajaxToolkit:TextBoxWatermarkExtender ID="TBWE" runat="server"
TargetControlID="Password"
WatermarkText="Type First Name Here"
WatermarkCssClass="watermarked" />

and do similar at other textbox controls that need a watermark (obviously editing ID "TBWE" to "TBWE2" etc. and setting TargetControlID to the ID of the textbox control that needs to get a watermark behaviour)

or did I miss something?
This content has not been rated yet. 
15 Reputation 5 Total posts
GeorgeBirbilis5

GeorgeBirbilis5

9/18/2012 2:10:45 PM
A question is where should one put <%@ Register ...>, at the LoginModule.ascx control or at the master page - or is it already registered anyway by MonoX at web.config [as shown at http://www.west-wind.com/weblog/posts/2009/May/04/Adding-Default-Assemblies-Namespaces-and-Control-Prefixes-in-WebConfig] and there is no need to use <%@ Register ... at all?
This content has not been rated yet. 
15 Reputation 5 Total posts
denis

denis

9/18/2012 2:42:53 PM
You don't have to worry about the "Register" directive, as it is not registering any actual scripts to the page; it is used by the compiler and VS as a kind of hint on where to find the actual server side controls that are specified on the page.
So, you can have it on the module level (and yes, we have that declaration in the main master page, but you should not worry about it), and you don't have to have it in the web.config at all - web.config is used when you want to register assemblies/tag prefixes on the global level, we are not registering AjaxControlToolkit there.
ToolkitScriptManager is not used in MonoX.

This content has not been rated yet. 
7207 Reputation 956 Total posts
GeorgeBirbilis6

GeorgeBirbilis6

9/19/2012 1:38:21 PM
We did make the watermark extender of AJAX control toolkit work (using the latest AJAX control toolkit as per the instructions at http://www.mono-software.com/Mono/Pages/Discussion/dtopic/tMKlkb6dcUWfI6CnANPaxg/AJAX-Control-Toolkit/?username=mzilic and http://www.mono-software.com/Mono/Pages/Discussion/dtopic/5g2sMDkZR0KyP57eAJewDw/Danish-alphabet/?dmsgId=1oZZcSW2IkGAkZ7gAQRexg#Post1oZZcSW2IkGAkZ7gAQRexg [this last one had the extra info that you need to place the runtime section just before the </configuration> at the end of the web.config file] - seems the June 2012 DLL has the same file version [right click the DLL and select Properties in Windows Explorer to see it] as the binding declaration suggested in those posts 4.x something so we just copied the suggested setting as it was)

It seems that in the "bin" folder of MonoX you need to apart from replacing AjaxControlToolkit.dll (got .NET4 version as our MonoX installation from http://ajaxcontroltoolkit.codeplex.com/releases/view/90063) add the folder SanitizerProviders from the AJAX control toolkit distro (there are some localized resource folders there that one could also copy to the "bin" folder)

Moreover AT THE LEVEL OF THE .ASCX file (the LoginModule.ascx at MonoX\ModulesGallery) we added <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %> cause we wer getting message that ajaxToolkit:TextBoxWaterMarkExtender tag is unknown. Probably those Register declarations aren't inherited from the master page (we use our own master page but it inherits from MonoX.master main master page which does have that declaration). I guess they need to be at the XML file level for the parser/compiler of ASP.net to understand the tag
This content has not been rated yet. 
0 Reputation 1 Total posts
denis

denis

9/19/2012 1:59:14 PM
Thanks for the info. You are correct - "Register" declarations are not inherited in any scenario. You can place them in the web.config to be available globally, but we are doing that only for the controls/namespaces that are really frequently used. In any case, we still prefer a "lightweight" jQuery approach I mentioned above, but I understand that you had different goals.
This content has not been rated yet. 
7207 Reputation 956 Total posts