7/4/2025 4:29:49 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
|
|
|
|
Accessing TabWorkSpace at Load
Posted: 28 Oct 09 6:25 AM
|
Help!
I'm trying to format phone controls, so that only numbers can be entered into them - it's the easiest way to ensure that all phone numbers are in the same format!! Unfortunately UK telephone formats aren't as uniform as US ones...
On Base.Master I've stuck a javascript function to only allow entering numerical characters and I can loop through all the controls in the maincontent in the Page_Load event using:
foreach (Control c in MainContent.Controls[0].Controls) { if (c.GetType() == typeof(Phone)) { Phone phone = c as Phone; phone.Attributes.Add("onkeypress", "forceNumOnly()"); } }
For some reason I can't seem to do the same with the tabworkspace. I've tried:
foreach (Control c in TabControl.Controls[0].Controls) { if (c.GetType() == typeof(Phone)) { Phone phone = c as Phone; phone.Attributes.Add("onkeypress", "forceNumOnly()"); } }
As far as I can make out, at Page_Load there isn't anything in the TabWorkSpace, so I need some way of triggering the loop when the current tab is loaded. Does anyone know when this happens?
BTW. I don't think Controls[0] is the right one, but it's hard to investigate when there's nothing loaded.
Hope you can help! |
|
|
|
Re: Accessing TabWorkSpace at Load
Posted: 28 Oct 09 7:19 AM
|
Bit of a numpty moment! I realised that the tab would probably loaded at the point of PreRender, so I had a bit of a play with that - I also realised that I wasn't catering for the DialogWorkspace.
I've added the below, which seems to be working. However, it's a bit messy and I'm worried that some controls may not load in exactly the same order, therefore stopping this from working :-S
protected void Page_PreRender(object sender, EventArgs e) { foreach (Control t in TabControl.Controls) { if (t.GetType() == typeof(TabElement)) { foreach (Control c in t.Controls[0].Controls[0].Controls[0].Controls[1].Controls) { if (c.GetType() == typeof(Phone)) { Phone phone = c as Phone; phone.Attributes.Add("onkeypress", "forceNumOnly()"); } } } }
foreach (Control c in DialogWorkspace.Controls[0].Controls[0].Controls[0].Controls) { if (c.GetType() == typeof(Phone)) { Phone phone = c as Phone; phone.Attributes.Add("onkeypress", "forceNumOnly()"); } } }
If anyone can help me tidy this up a little bit I'd be grateful! |
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|