I'm currently using the Infragistics component set for .Net 2.0, Visual Studio 2005 and C#. I have the following chunk of javascript code (text and other variables are declared elsewhere):
***alert(box[select].value);
text.value(box[select].value);
alert(text.value);***
'text' is an Infragistics webTextEdit, while box is just a standard listbox. The two alerts seem to be working fine. Before I set the value, the listBox's selected value might be 'hello', and the alert box which pops up after I've assigned this value to 'text' is also 'hello'.
However, the value shown in the box on my form never appears to get updated. Anybody have some suggestions as to where I'm going wrong, gotchas in how Infragistics handles this kind of thing or anything else? I'm aware there may not be enough info here to diagnose the problem.
The value property is only available server-side. Using it client-side won't do anything. Setting it would have to be done server-side, or you'll need to craft fun javascript to address the text of the element that the control is actually rendered as in the browser.
http://help.infragistics.com/Help/NetAdvantage/NET/2007.3/CLR2.0/html/Infragistics2.WebUI.WebDataInput.v7.3~Infragistics.WebUI.WebDataInput.WebTextEdit~Value.html
Unless I misunderstand the question, if text is an instance of the Infragistics WebTextEdit, you should just be able to do:
text.setValue(box[select].value)
Or if text is the underlying input control, but 'id' is the ID of it,
var edit = igedit_getById(id)
edit.setValue(box[select].value)
See the WebTextEdit CSOM for more.
Related
I am new to .NET & Bootstrap and am required to use the .ASPX single file ASP.NET type code AND use Bootstrap and its slider. I have the Slider control below
<input type="text"
runat="server"
value="7"
class="slider-horizontal"
id="_sl1"
data-slider-min="0"
data-slider-max="10"
data-slider-step="1"
data-slider-value="7"
data-slider-orientation="horizontal"
data-slider-selection="after"
data-slider-tooltip="show">
and need to set the data-slider-value in the server side C# code in the on page_load event, then read it back on post_back, BUT I don't appear to be able to do this, and can find no information on how to do it except client side via javascript. I see the value property but setting that appears to do nothing.
I believe the problem is the text box used for the slider is mapped to
System.Web.UI.HtmlControls.HtmlInputText by .NET, hence the presence of the Value property, but the Slider properties I see in the HTML code are not recognised in the server C# code so can't be accessed. Any help or pointers to appropriate information as to how to then use this control to access the values on the server side would be most welcome. I have spent some days trying to find a solution, not helped by the lax terminology that means Slider picks up Carousel related links! I've also followed Bootstrap courses , at least 3 so far and they too fail to provide an answer.
First of all, thanks to everyone who tidied up the mess I made of this post, and now my answer to my problem, it is simple, which is probably why I spent days looking for it. Use the Attribute method of the control.
.Attributes.Add("data-slider-value", theValue);
I am writing to you because I want to understand what is happening.
In my code, I add controls dynamically to the System.Web.UI.WebControls.GridView (I extended it). After some action on the page, I am checking if the ID of the Control from Page.Request["__EVENTTARGET"] is the one, which I saved earlier in ViewState.
On .Net 3.5 everything works fine, but after switching my project to .Net 4 this doesn't work, because Page.Request["__EVENTTARGET"] returns Inherit ClientId, and I keeped in ViewState only short Id of my control. I fixed it by using Page.FindControl method. It works for LinkButtons, Buttons and DropDowns, but not for TextBoxes, because Page.Request["__EVENTTARGET"] returns name of my TextBox...
So I change ClientIdMode for my TextBox to Static, like 'string$string'. But still Page.FindControl was returned null. I have read that if TextBox is generated dynamically and it is nested in some controls, this method is not able to find it.
My first question. Why method Page.FindControl is not able to find nested TextBox, but it can handle with others control like DropDown or LinkButton?
But I handle this problem also. I wrote recursive kind of Page.FindControl and I can find my TextBox. But in this moment I came across a problem again. Value of this TextBox is old (I write 6, but in the Text property there is still 1). My first idea was that this is because I was doing it too early - in OnPagePreLoad method.
But then I change Id of my TextBox from string$string to 'string_string' and it started to work fine (value of my text box is that I wrote).
And this is my second question. Why dollar ($) sign cause I saw the old value?
Thanks !!
The $ character is not valid in the ID property. See this Microsoft article for more information
Specifically,
Only combinations of alphanumeric characters and the underscore character ( _ ) are valid values for this property. Including spaces or other invalid characters will cause an ASP.NET page parser error.
Also, see this Microsoft article about the IdSeparator property.
Specifically:
This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.
So replacing the $ with an underscore seems like the right answer.
I'm trying to add the OnChange or Changed or IndexChanged event to the "Drop-down list box" control in InfoPath using VS Tools for applications.
If found the following code how this is done with buttons:
((ButtonEvent)EventManager.ControlEvents["ButtonName"]).Clicked += new ClickedEventHandler(FormCode_Clicked);
I would think this is also possible with other controls, but I can't seem to find the cast object to be able to add the event to my drop-down list.
((?)EventManager.ControlEvents["Project_x0020_Number"]).SelectedIndexChanged += new EventHandler(FormCode_SelectedIndexChanged);
I tried the object ComboBox, but then their was an error that this object could not be casted to the type ComboBox.
I hope someone can give me some advice. All I want to do is basically run a Query that filters my data depending on the selected value in my "Project Number" box.
maybe also good to mention: I'm changing the form that will go in a word document (used as template in SharePoint). I don't really think this matters, but thought I mention it any way.
Thanks in advance
Oxillery
You can approach this problem without writing code. I dont have Infopath in this machine to give you a sample. But I think you can solve this with the method described here in point 26:
http://www.bizsupportonline.net/infopath2003/avg-function-infopath.htm
Instead of calculating the average as in the example above you will set some parameters in your datasource and perform a refresh based on the value set in your dropdown.
I'm currently trying to implement a simple Add-In for InfoPath 2010 Filler/Editor mode, which adds a few buttons on the "Insert" ribbon, which upon clicking inserts some "template" data from another source.
It works fine but the thing that's annoying me is that when the user has no field selected, it remains enabled while all of the other buttons on the insert toolbar somehow "know" that nothing can be inserted in the current context and are therefore disabled.
The MSDN documentation on how to interact with the underlying XDocument is perfectly adequate, but what I'm struggling to figure out is how to interact or get information from the editing UI.
This is what I'd like to have:
An event that gets fired when the user changes from field to field on the form
Then be able to tell what kind of field the user is currently entering data into (i.e. rich text, plain text etc), so the extra buttons can be enabled or disabled as needed.
I thought this would be fairly simple but I've spent nearly a day looking through everything I can find, and have come up empty!
Or have I completely missed the point here?
Several months later I can finally answer my own question. Not that anyone uses InfoPath filler, but just in case anyone does, here's my solution:
There's several points to my original question.
1) Event that gets fired when the user changes from field to field:
This turns out to be specified in the Ribbon Button XML as the "getEnabled" attribute. InfoPath calls the specified function each time it thinks the button may need to be enabled or disabled. On mine I specified: getEnabled="OnButtonGetEnabled", then implemented a small function:
public bool OnButtonGetEnabled(Office.IRibbonControl control)
{
ribbon.Invalidate();
return HaveRichTextFieldSelected(GetContextXPath());
}
in my case 'ribbon' is my instance of Office.IRibbonUI. Calling 'Invalidate()' is pretty important otherwise InfoPath only ends up calling this once.
2) How to determine the type of the field the user has selected.
I'm still not happy with my solution for this but at least I now have something that works.
I've written two functions:
1: GetContextXPath() which calls Globals.ThisAddIn.Application.ActiveWindow.XDocument.View.GetContextNodes(), builds an XPath string from the result (walking backwards through the DOM tree)
2: HaveRichTextFieldSelected() which checks if the specified XPath is of type 'rich' in the manifest (whose DOM tree is under Globals.ThisAddIn.Application.ActiveWindow.XDocument.Solution.DOM)
Anyway I'm not posting all of the code involved here as it's too much for an SO answer, but this should give someone with some common sense a clue as to how to implement this.
I'm working on a spellcheck function for my app, and want to have the word that's currently being looked at highlighted. I'm tracking the char count as I loop through the words in the textbox, so I know where to set the selection at.
I've tried txtArticle.Select(0, 10); just as a test, as well as setting the txtArticle.SelectionStart and txtArticle.SelectionLength properties, but the textbox doesn't show anything highlighted. What's the dealio?
Actual code I've tried:
txtArticle.SelectionStart = charCount;
txtArticle.SelectionLength = checkedWord.Length;
as well as
txtArticle.Select(charCount, checkedWord.Length);
I've positively no idea what I'm doing wrong, unless you can't set what's selected in the TextBox via code, which I just can't imagine is the case. Is there perhaps some extra property that I need to set for the TextBox itself?
Thanks yet again!
-Sootah
Documentation on MSDN of TextBox.SelectionStart Property has an example that works. This states that programmatic text selection is actually supported in Silverlight.
Looks like something else is going wrong in your application. When do you call this code? Try calling it after everything is loaded, and rendered on screen. May be on a click of a button.
If above does not work, create a sample application/page and try to follow MSDN example. When you get it working, try to figure out why it doesn't work in your application.