Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
111 views
Hi All,

I have a requirement where i need to add the controls to the page dynamically

here i have 5 sections under each section there will be fields that are to be added dynamically....

i am adding these 5 sections as radpanelitems....

and under each panel item i added a table in which the controls based on the datatype are added to the cells as rows to the table
dynamically.

in brief(that is if i have the datatype for a field as varchar(50) then i will add the textbox control... like wise..)

at the end of the page ... i have add button...

on the click of 'add' button i need to get the values entered in the controls by the end user.

how do i...

i tried using Request.Form["txtRequirementname"].toString()...

it isthrowing the exception 'object reference is not set to an instance"

did i do some thing mistake here... or is there any other way to retrieve the values of the controls.

below is the code written to add the controls to the table.

and also i attached a image of file 

 

private void AddControlstoRow(HtmlTableRow htRow, FieldDefinition fd, double labelwidth, double controlwidth, int colspan)

 

{

 

if (!fd.FieldDataTypeReference.IsLoaded)

 

{

fd.FieldDataTypeReference.Load();

}

 

//for adding label control

 

 

HtmlTableCell htcell = new HtmlTableCell();

 

htcell.Width =

Unit.Percentage(labelwidth).ToString();

 

htcell.Align =

"left";

 

 

Label lblName = new Label();

 

 

if (fd.ListPageMandatory == "Y")

 

{

lblName.Text = fd.FieldLiteral +

":" + "<font color='red'>&nbsp;*</font>";

 

}

 

else

 

{

lblName.Text = fd.FieldLiteral +

":";

 

}

 

//lblName.ForeColor = System.Drawing.Color.Red;

 

 

//lblName.CssClass = strCellCss;

 

htcell.Controls.Add(lblName);

htRow.Cells.Add(htcell);

 

//adding control as per fielddatatypeid

 

 

HtmlTableCell htControlcell = new HtmlTableCell();

 

htControlcell.Width =

Unit.Percentage(controlwidth).ToString();

 

htControlcell.Align =

"Left";

 

htControlcell.ColSpan = colspan;

 

TextBox txtBox = new TextBox();

 

txtBox.EnableViewState =

true;

 

txtBox.ID =

"txt" + fd.FieldLiteral;

 

 

switch (fd.FieldDataType.FieldDataTypeID)

 

{

 

case 12:

 

txtBox.CssClass =

"TextBox";

 

htControlcell.Controls.Add(txtBox);

 

if ((fd.FieldLiteral.ToUpper().Trim().Contains("TIME") || fd.FieldLiteral.ToUpper().Trim().EndsWith("EFFORT") || fd.FieldLiteral.ToUpper().Trim().Contains("DURATION")) && (fd.FieldDataType.FieldDataTypeID != 16))

 

{

 

Label lblUnits = new Label();

 

lblUnits.Text =

"&nbsp;&nbsp;<I>[Hrs]</I>";

 

htControlcell.Controls.Add(lblUnits);

}

 

break;

 

 

case 13:

 

txtBox.CssClass =

"TextBox";

 

txtBox.TextMode = System.Web.UI.WebControls.

TextBoxMode.MultiLine;

 

txtBox.Width = System.Web.UI.WebControls.

Unit.Pixel(550);

 

txtBox.Height = System.Web.UI.WebControls.

Unit.Pixel(50);

 

htControlcell.Controls.Add(txtBox);

 

break;

 

 

case 14:

 

txtBox.CssClass =

"TextBox";

 

 

if ((fd.FieldLiteral.ToUpper().Trim().Contains("TIME") || fd.FieldLiteral.ToUpper().Trim().EndsWith("EFFORT") || fd.FieldLiteral.ToUpper().Trim().Contains("DURATION")) && (fd.FieldDataType.FieldDataTypeID != 16))

 

{

txtBox.Width = System.Web.UI.WebControls.

Unit.Pixel(60);

 

htControlcell.Controls.Add(txtBox);

 

Label lblUnits = new Label();

 

lblUnits.Text =

"&nbsp;&nbsp;<I>[Hrs]</I>";

 

htControlcell.Controls.Add(lblUnits);

}

 

else

 

{

txtBox.Width = System.Web.UI.WebControls.

Unit.Pixel(140);

 

htControlcell.Controls.Add(txtBox);

}

 

break;

 

 

case 18:

 

 

DropDownList ddlLOV = new DropDownList();

 

ddlLOV.ID =

"ddl" + fd.FieldLiteral;

 

ddlLOV.CssClass =

"DDL";

 

ddlLOV.EnableViewState =

true;

 

ddlLOV.Width = System.Web.UI.WebControls.

Unit.Pixel(185);

 

ddlLOV.Items.Add(

new ListItem("--Select--"));

 

 

List<ListOfValues> lstValues = new RequirementBO().SelectListOfValues(fd.FieldID, 4, 36);

 

 

for (int i = 0; i < lstValues.Count; i++)

 

{

 

ListItem li = new ListItem(lstValues[i].ListDescription, lstValues[i].ValueID.ToString());

 

ddlLOV.Items.Add(li);

}

htControlcell.Controls.Add(ddlLOV);

 

break;

 

 

case 24:

 

 

DropDownList ddsdlLOV = new DropDownList();

 

ddsdlLOV.ID =

"ddl" + fd.FieldLiteral;

 

ddsdlLOV.CssClass =

"DDL";

 

ddsdlLOV.EnableViewState =

true;

 

ddsdlLOV.Width = System.Web.UI.WebControls.

Unit.Pixel(185);

 

ddsdlLOV.Items.Add(

new ListItem("--Select--"));

 

 

List<Module> lstModules = new RequirementBO().selectModules(4);

 

 

for (int i = 0; i < lstModules.Count; i++)

 

{

 

ListItem li = new ListItem(lstModules[i].ModuleName, lstModules[i].ModuleCode.ToString());

 

ddsdlLOV.Items.Add(li);

}

htControlcell.Controls.Add(ddsdlLOV);

 

break;

 

 

case 16:

 

 

RadDatePicker rdPicker = new RadDatePicker();

 

rdPicker.Skin =

"Simple";

 

rdPicker.Width = System.Web.UI.WebControls.

Unit.Pixel(150);

 

htControlcell.Controls.Add(rdPicker);

 

if ((fd.FieldLiteral.ToUpper().Trim().Contains("TIME") || fd.FieldLiteral.ToUpper().Trim().EndsWith("EFFORT") || fd.FieldLiteral.ToUpper().Trim().Contains("DURATION")) && (fd.FieldDataType.FieldDataTypeID != 16))

 

{

 

Label lblUnits = new Label();

 

lblUnits.Text =

"&nbsp;&nbsp;<I>[Hrs]</I>";

 

htControlcell.Controls.Add(lblUnits);

}

 

break;

 

 

case 17:

 

 

RadDateTimePicker rdtPicker = new RadDateTimePicker();

 

rdtPicker.Skin =

"Simple";

 

rdtPicker.Width = System.Web.UI.WebControls.

Unit.Pixel(150);

 

htControlcell.Controls.Add(rdtPicker);

 

if ((fd.FieldLiteral.ToUpper().Trim().Contains("TIME") || fd.FieldLiteral.ToUpper().Trim().EndsWith("EFFORT") || fd.FieldLiteral.ToUpper().Trim().Contains("DURATION")) && (fd.FieldDataType.FieldDataTypeID != 16))

 

{

 

Label lblUnits = new Label();

 

lblUnits.Text =

"&nbsp;&nbsp;<I>[Hrs]</I>";

 

htControlcell.Controls.Add(lblUnits);

}

 

break;

 

 

case 23:

 

 

break;

 

 

case 25:

 

 

break;

 

 

case 15:

 

txtBox.CssClass =

"TextBox";

 

 

if ((fd.FieldLiteral.ToUpper().Trim().Contains("TIME") || fd.FieldLiteral.ToUpper().Trim().EndsWith("EFFORT") || fd.FieldLiteral.ToUpper().Trim().Contains("DURATION")) && (fd.FieldDataType.FieldDataTypeID != 16))

 

{

txtBox.Width = System.Web.UI.WebControls.

Unit.Pixel(60);

 

htControlcell.Controls.Add(txtBox);

 

Label lblUnits = new Label();

 

lblUnits.Text =

"&nbsp;&nbsp;<I>[Hrs]</I>";

 

htControlcell.Controls.Add(lblUnits);

}

 

else

 

{

txtBox.Width = System.Web.UI.WebControls.

Unit.Pixel(160);

 

htControlcell.Controls.Add(txtBox);

}

 

break;

 

}

htRow.Cells.Add(htControlcell);

}



Thanks in Advance
Regards:
Chaitanya.E

Schlurk
Top achievements
Rank 2
 answered on 15 Mar 2010
5 answers
294 views
Hello,

I have a CustomLinkManager to handle the link creation in my editor but when I select a created link to edit it, it create an other <a> tag witch contain the one selected. My problem is that I need to replace the current selection, is there something like editor.ReplaceSelection(html) ?

 Thanks for the help!

Vincent

My code looks like this : 

Telerik.Web.UI.Editor.CommandList["CustomLinkManager"] = function(commandName, editor, args) { 
                    var elem = editor.getSelectedElement(); //returns the selected element. 
 
                    if (elem.tagName == "A") { 
                        editor.selectElement(elem); 
                        argument = elem
                    } 
                    else { 
                        var content = editor.getSelectionHtml(); 
                        var link = editor.get_document().createElement("A"); 
                        link.innerHTML = content
                        argument = link
                    } 
 
                    var myCallbackFunction = function(sender, args) { 
                        var html = String.format("<href=\"{0}\" target=\"{1}\" class=\"{2}\" title=\"{3}\">{4}</a>", args.url, args.target, args.className, args.title.replace("'", "\'"), args.name); 
                        editor.pasteHtml(html) 
                         
                    } 
 
                    editor.showExternalDialog('<%= Page.ResolveUrl("~/aspx/cms/CustomLinkManager.aspx") %>', argument, 600, 600, myCallbackFunction, null, 'Insérer un lien', true, Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, false, true); 
                }; 


Dobromir
Telerik team
 answered on 15 Mar 2010
1 answer
105 views
Schlurk
Top achievements
Rank 2
 answered on 15 Mar 2010
1 answer
206 views
hi
i have a radwindow with skin default.
i want  overwirte the css class to obtain a custom style that have for example the property top and right sets by me.
in which way can i make it?
thank in advice
Schlurk
Top achievements
Rank 2
 answered on 15 Mar 2010
1 answer
370 views
Hi All,

How to set Line Chart Series Line color through Properties options or in Inline code, Please help me regarding this.
Schlurk
Top achievements
Rank 2
 answered on 15 Mar 2010
3 answers
153 views
I was setting up some properties in the codebehind for the file explorer, and I came across some properties that don't seem to work as expected.

 

fileExplorer.Upload.AllowedFileExtensions  
fileExplorer.Configuration.SearchPatterns  
 
fileExplorer.Upload.MaxFileSize  
fileExplorer.Configuration.MaxUploadFileSize  
 
It appears to me that the properties for .Upload do not work, and they seem to be redundant if there are configuration properties that seem to have the same purpose. Were they accidentally left in when the configuration properties were created?
I believe I am using the 2009 Q3 release, but it could be Q2

When I added values to the AllowedFileExtensions, they did not show up on the upload form file extensions list, but when I used the SearchPatterns property, they showed up.

Sorry if this has already been fixed.
Lini
Telerik team
 answered on 15 Mar 2010
2 answers
111 views
I am trying to update a list box on the parent when a radwindow closes.  The listbox is populated from a database in code behind.  Actuallly happens on a dropdown_selected index change event.  Just want to load the listobx with the new data when the user closes the radwindow.

One more think I have an update panel and when I tried to ues a RadAjaxManager they clashed.
Eric Klein
Top achievements
Rank 1
 answered on 15 Mar 2010
1 answer
146 views

H! there

I wanted to know some details about telerik controls with respect to telerki Salesdshaboard.

I have seen two salesdashboard one made using ASP.NET, AJAX Rad Controls, Silverlight Rad Controls and OpenAccessORM.
and other using Silverlight Rad Controls only. I Have gont through both telerik salesboard.

The salesdashboard made in ASP.NET, AJAX Rad Controls, Silverlight Rad Controls and OpenAccessORMhas more appealing and detailed UI compare to one made in Silverlight. 

I want to know can i achieve the same level of customization using SilverlighRadControls only.

What is the difference in two salesboard? does that give more performance combining all three  ASP.NET, AJAX Rad Controls, Silverlight Rad Controls and OpenAccessORM.

what is the role of OpenAccessORM?  Can i achive the same UI using silverlight rad controls instead of combining all three. The salesboard made in silverlight was not so appealing compare to the one made in using ASP.NET, AJAX Rad Controls, Silverlight Rad Controls and OpenAccessORM.


Please do reoply me mentioning all details asap.

Thank you

Regards
Vijay Gaur
Tihomir Petkov
Telerik team
 answered on 15 Mar 2010
3 answers
179 views
The radEditor has a clientside api called setFocus, thats supposed to set focus to the control. I'm not much of a javascript programer, so I would like to make a function from serverside code with a parameter for the actuall radEditor control to set focus to this control.

On the serverside we could set the function by something like:

ClientScript.RegisterStartupScript(Me.GetType, "Key", sb.ToString)

Where the actual function is buildt with stringbuilder.

In the masterpage we have this function:

 

<script type="text/javascript" language ="javascript" > 
    function SetEditorFocus(id) {  
        var editor = document.getElementById(id);  
        editor.setFocus();  
        return true;  
    }  
</script> 
 

Is this function ok?

If it's ok, what to put into the stringbuilder to get this to work from serverside?

 

 

 

 

Rumen
Telerik team
 answered on 15 Mar 2010
1 answer
104 views
I have a radcombox and a span next to each other.  I want to set the style.display = "none" of sBtns when a certain item is selected in the combo box.  How do I access the span object in client side script?

                <telerik:radcombobox id="cboPortfolioView" runat="server" tabindex="1"   
                    onclientselectedindexchanged="SectorAcctTypeDisplay">  
                            </telerik:radcombobox> 
                <span id="sBtns" runat="server">  
                    <asp:RadioButton ID="radAll" runat="server" Checked="True" GroupName="SectorAcctType" 
                        Text="All" /> 
                    <asp:RadioButton ID="radAfs" GroupName="SectorAcctType" Text="AFS" runat="server" /> 
                    <asp:RadioButton ID="radHtm" GroupName="SectorAcctType" Text="HTM" runat="server" /> 
                </span> 

<script language="javascript" type="text/javascript">  
<!--  
    function SectorAcctTypeDisplay(sender, eventArgs) {  
        var item = eventArgs.get_item();  
        var val = item.get_value();  
        alert("val: " + val);  
 
        if (val == "0") {  
            sBtns.style.display = "none";  
        }  
    }  
-->  
</script> 


Thanks in advance.
Simon
Telerik team
 answered on 15 Mar 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?