Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
240 views
Hi,

I'm having some challenges hiding/showing a RadTextBox.
The set_visible client side method does not seem to work, so I'm using the following:
  document.getElementById('<%= txtURL.ClientID %>').style.display = 'block';

This makes the box visible, but as soon as I move the mouse over the field, it disappears!
Also, once the box is visible if I check another radio button like File, and then come back and check Link, the box does not reappear.
It seems that it only shows the first time I check the Link button.
Happening in IE, FF and Chrome.

Here's my complete scenario (see attached screenshot).
I have 3 radio buttons all of which have an OnClientCheckedChanged event defined.
These event handlers hide/show relevant controls.
I check the None radio button and hide all of the related labels/controls in the Page_Load event (code behind).

Here's the relevant code snippets.

Code Behind:
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            lblURL.Style.Add("display", "none");
            txtURL.Style.Add("display", "none");
            lblUpload.Style.Add("display", "none");
            uplAttachment.Style.Add("display", "none");
            lblFileName.Style.Add("display", "none");
            lblFileNameValue.Style.Add("display", "none");
 
            optAttachment.Checked = false;
            optURL.Checked = false;
            optNone.Checked = true;
 
            taskID = Request.QueryString["taskID"].ToString();
            txtTaskID.Text = taskID;
        }
    }

RadTextBox declaration:
<tr>
                        <td class="templateLabel">
                            <asp:Label ID="lblURL" ToolTip="Specify a link (must start with http:// or https://)"
                                runat="server" Text="Link:"></asp:Label>
                            <asp:Label ID="lblFileName" ToolTip="File Name of last upload"
                                runat="server" Text="File Name:"></asp:Label>
                        </td>
                        <td class="templateValue">
                            <telerik:RadTextBox ID="txtURL" MaxLength="300" runat="server" EmptyMessage="Specify a link (must start with http:// or https://)"
                                Width="450px"
                                Enabled='<%# (Boolean)Session["EditProcess"] %>'>
                            </telerik:RadTextBox>
                            <asp:Label ID="lblFileNameValue" Text="File Name goes here" ToolTip="File Name of last upload"
                                runat="server"></asp:Label>
                        </td>
                    </tr>

Radio Buttons:
<tr>
    <td class="templateLabel">
         <asp:Label ID="lblAttachmentType" runat="server" Text="Reference:"></asp:Label>
    </td>
    <td class="templateValue">
        <telerik:RadButton runat="server" AutoPostBack="False" Enabled='<%# (Boolean)Session["EditProcess"] %>' ID="optAttachment" ButtonType="ToggleButton" ToggleType="Radio" GroupName="urlOrAtt" Text="File" Value="attachment" OnClientCheckedChanged="optAttachment_CheckedChanged"></telerik:RadButton>
        <telerik:RadButton runat="server" AutoPostBack="False" Enabled='<%# (Boolean)Session["EditProcess"] %>' ID="optURL" ButtonType="ToggleButton" ToggleType="Radio" GroupName="urlOrAtt" Text="Link" Value="url" OnClientCheckedChanged="optUrL_CheckedChanged"></telerik:RadButton>
        <telerik:RadButton runat="server" AutoPostBack="False" Enabled='<%# (Boolean)Session["EditProcess"] %>' ID="optNone" ButtonType="ToggleButton" ToggleType="Radio" GroupName="urlOrAtt" Text="None" Value="none" OnClientCheckedChanged="optNone_CheckedChanged"></telerik:RadButton>
    </td>
</tr>

OnClientCheckedChanged Handlers:
function optUrL_CheckedChanged(sender, eventArgs) {
            if (!g_rowSelected) {
                if (sender.get_checked()) {
                    alert('Link selected');
                    //var txtURL = $find("<%=txtURL.ClientID%>");
                    //txtURL.clear();
                    //txtURL.set_visible(true);
                    document.getElementById('<%= txtURL.ClientID %>').style.display = 'block';
                    document.getElementById('<%= lblURL.ClientID %>').style.display = 'block';
                    $find("<%=uplAttachment.ClientID%>").set_visible(false);
                    document.getElementById('<%= lblUpload.ClientID %>').style.display = 'none';
                    document.getElementById('<%= lblFileName.ClientID %>').style.display = 'none';
                    document.getElementById('<%= lblFileNameValue.ClientID %>').style.display = 'none';
                }
                EnableSave();
            }
        }
 
        function optAttachment_CheckedChanged(sender, eventArgs) {
            if (!g_rowSelected) {
                if (sender.get_checked()) {
                    alert('File selected');
                    var txtURL = $find("<%=txtURL.ClientID%>");
                    txtURL.clear();
                    txtURL.set_visible(false);
                    document.getElementById('<%= lblURL.ClientID %>').style.display = 'none';
                    $find("<%=uplAttachment.ClientID%>").set_visible(true);
                    document.getElementById('<%= lblUpload.ClientID %>').style.display = 'block';
                    document.getElementById('<%= lblFileName.ClientID %>').style.display = 'block';
                    document.getElementById('<%= lblFileNameValue.ClientID %>').style.display = 'block';
                }
                EnableSave();
            }
        }
 
        function optNone_CheckedChanged(sender, eventArgs) {
            if (!g_rowSelected) {
                if (sender.get_checked()) {
                    alert('None selected');
                    var txtURL = $find("<%=txtURL.ClientID%>");
                    txtURL.clear();
                    txtURL.set_visible(false);
                    document.getElementById('<%= lblURL.ClientID %>').style.display = 'none';
                    $find("<%=uplAttachment.ClientID%>").set_visible(false);
                    document.getElementById('<%= lblUpload.ClientID %>').style.display = 'none';
                    document.getElementById('<%= lblFileName.ClientID %>').style.display = 'none';
                    document.getElementById('<%= lblFileNameValue.ClientID %>').style.display = 'none';
                }
                EnableSave();
            }
        }


Any thoughts?

My thanks in advance.

Jim
jlj30
Top achievements
Rank 2
 answered on 19 May 2014
2 answers
182 views
I need to access an image control (img1) which nests within a second table in my Radlistview. Is this possible to do via ItemDatabound.
Here is the Radlistview:
 
<telerik:RadListView ID="radlist1" runat="server" ItemPlaceholderID="ListViewContainer" DataKeyNames="ID">
    <LayoutTemplate>
            <asp:PlaceHolder runat="server" ID="ListViewContainer"></asp:PlaceHolder>
    </LayoutTemplate>
       <ItemTemplate>
            <fieldset>
                  <legend><strong><%# Eval("Name")%></strong></legend>
                        <table >
                             <tr>
                                 <td>
                                        <table >
                                              <td>
                                                   <strong> <%# Eval("Title")%></strong> 
                                               </td>
                                                <td valign="top" style="width:52px;" >
                                                      <asp:Image ID="img1" runat="server"  />
                                                  </td>
                                            </table>
                                    </td>
                                </tr>
                                 <tr>
                                 </tr>
                             </table>
                        </fieldset>
                    </ItemTemplate>
             </telerik:RadListView>
K W
Top achievements
Rank 1
 answered on 19 May 2014
1 answer
144 views
Hi,

is there a control like the expnader control in wpf for asp.net Ajax?

Thanks
Best Regards
Rene
Princy
Top achievements
Rank 2
 answered on 19 May 2014
3 answers
189 views
Hi,

i use a Grid to Display a Datatable. I select the Data with an SQL-Statement. But how do i display the value from the inner join (second table)?

DataTable Kommentare
    {
        get
        {
            if (Object.Equals(Session["Kommentare"], null))
            {
                string query = "SELECT id, paketid, kommentar, bewertung, produkt FROM [kommentare] INNER JOIN [rating] ON kommentare.paketid = rating.id";
                DataTable dt = GetDataTable(query);
                 
                Session["Kommentare"] = dt;                               
            }
            return (DataTable)Session["Kommentare"];
        }
        set
        {
            Session["Kommentare"] = value;
        }
    }

How do is diaply "produkt " which is a field from table "kommentare"?

<telerik:GridBoundColumn AllowSorting="true" DataField="produkt" HeaderText="Produkt" SortExpression="Produkt" UniqueName="produkt"  />

will not work!

Thanks
best Regards
Rene
ITA
Top achievements
Rank 1
 answered on 19 May 2014
7 answers
490 views

Hi

I’m using hierarchy RadGrid for my application, in which I’m using the master/parent table to show the total amount of the detail table row amounts. So when the user updates the amount in detail table, I have to update the total amount in the master table.  But the master table doesn’t refresh automatically after the detail table is updated. When I try to rebind the grid after I update the detail table, it throws an exception saying “OrderDetailsID is neither a DataColumn nor a DataRelation for table Table.” I’m using ItemCommand method for updating detail table. Please help me to solve this problem.

 

Here is the Code:

 

protected void gridOrders_ItemCommand(object source, GridCommandEventArgs e)

{

lblStatus.Text = String.Empty;  
int OrderID; 

int OrderDetailsID;  
String ItemName;  
Double Amount;  

switch (e.CommandName.ToUpper())

{

case "UPDATE":  

if (e.Item.OwnerTableView.Name == "OrderDetails")

GridEditableItem editedItem = e.Item as GridEditableItem;

OrderDetailsID = int.Parse(editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["OrderDetailsID"].ToString());    

OrderID = int.Parse(editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["OrderID"].ToString());  

 ItemName = (editedItem[

"ItemName"].Controls[1] as RadTextBox).Text;  

 Amount = Double.Parse((editedItem["Amount"].Controls[1] as RadNumericTextBox).Text.ToString());  

 try 

 

 //Update Order Details 

 String cmdText = "UPDATE [OrderDetails] SET ItemName = '"+ ItemName +"', Amount = " + Amount + " WHERE OrderDetailsID = " + OrderDetailsID;

Database db = DatabaseFactory.CreateDatabase();
DbCommand dbCmd = db.GetSqlStringCommand(cmdText);
db.ExecuteNonQuery(dbCmd); 

 //Update Orders

 UpdateOrders(OrderID);

 gridOrders.MasterTableView.Rebind();  ---------------------------------------------->> This line causes the exception.

}

 catch (Exception ex)  

{

lblStatus.Text = ex.Message;

}

break;
}  

}

 

protected void gridOrders_NeedDataSource1(object source, GridNeedDataSourceEventArgs e)  

{

try
{
string cmdText = @"SELECT OrderID, PersonName, Amount FROM [Order]"
Database db = DatabaseFactory.CreateDatabase(); 
DbCommand dbCmd = db.GetSqlStringCommand(cmdText); 
DataSet orderDataSet = db.ExecuteDataSet(dbCmd); gridOrders.DataSource = (DataTable)orderDataSet.Tables[0];    

}

catch (Exception ex)
{

lblStatus.Text = ex.Message;

}

}

protected void gridOrders_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)
{

GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;

string OrderID = dataItem.GetDataKeyValue("OrderID").ToString();
if (e.DetailTableView.Name == "OrderDetails")

{ 

try
 

string cmdText = @"SELECT * FROM OrderDetails WHERE OrderID = " + OrderID; 

Database db = DatabaseFactory.CreateDatabase();  

DbCommand dbCmd = db.GetSqlStringCommand(cmdText);  

DataSet detailDataSet = db.ExecuteDataSet(dbCmd);

e.DetailTableView.DataSource = (DataTable)detailDataSet.Tables[0];

} 

catch (Exception ex)

{

lblStatus.Text = ex.Message;

}

}

}


 

<telerik:RadGrid ID="gridOrders" runat="server" AutoGenerateColumns="False" GridLines="None"  

 Width="600px" onitemcommand="gridOrders_ItemCommand" onneeddatasource="gridOrders_NeedDataSource1" ShowFooter="true"  

 ondetailtabledatabind="gridOrders_DetailTableDataBind" >

 <MasterTableView DataKeyNames="OrderID" Width="100%" Name="Orders">

 <DetailTables>

 <telerik:GridTableView DataKeyNames="OrderDetailsID,OrderID" Width="100%" runat="server"

 Name="OrderDetails" CommandItemDisplay="Top">

 <ParentTableRelation>

 <telerik:GridRelationFields DetailKeyField="OrderID" MasterKeyField="OrderID" />

 </ParentTableRelation>

 <Columns>

 <telerik:GridEditCommandColumn ButtonType="ImageButton">

 </telerik:GridEditCommandColumn>

 <telerik:GridTemplateColumn HeaderText="Item Name" UniqueName="ItemName">

 <ItemTemplate>

 <asp:Label ID="lblItemName" runat="server" Text='<%# Eval("ItemName") %>'></asp:Label>

 </ItemTemplate>

 <EditItemTemplate>

 <telerik:RadTextBox ID="tbItemName" runat="server" Text='<%# Bind("ItemName") %>'

 Width="135px" >

 </telerik:RadTextBox>

 <span style="color: Red">*</span>

 <asp:RequiredFieldValidator ID="rfvItemName" runat="server"

 ControlToValidate="tbItemName" ErrorMessage="Item Name is required!">

 </asp:RequiredFieldValidator>

 </EditItemTemplate>

 </telerik:GridTemplateColumn>

 <telerik:GridTemplateColumn HeaderText="Amount" UniqueName="Amount" >

 <ItemTemplate>

 <asp:Label ID="lblAmount" runat="server" Text='<%# Eval("Amount", "{0:C}") %>'></asp:Label>

 </ItemTemplate>

 <EditItemTemplate>

 <br />

 <telerik:RadNumericTextBox ID="tbAmount" Runat="server" Text='<%# Bind("Amount") %>'

 MinValue="0" Width="135px" NumberFormat-AllowRounding="True" NumberFormat-DecimalDigits="2">

</telerik:RadNumericTextBox>

<span style="color: Red">*</span>

<asp:RequiredFieldValidator ID="rfvAmount" runat="server"

ControlToValidate="tbAmount" ErrorMessage="Amount is required!">

</asp:RequiredFieldValidator>

</EditItemTemplate>

</telerik:GridTemplateColumn>

<telerik:GridButtonColumn CommandName="Delete" Text="Delete" ButtonType="ImageButton"

ConfirmText="Are you sure you want to delete this record?" ConfirmTitle="Confirm Delete" UniqueName="column">

</telerik:GridButtonColumn>

</Columns>

</telerik:GridTableView>

</DetailTables>

<Columns>

<telerik:GridBoundColumn DataField="PersonName" EmptyDataText="&amp;nbsp;"

 HeaderText="Name" UniqueName="PersonName">

 <HeaderStyle Height="20px" />

 </telerik:GridBoundColumn>

 <telerik:GridBoundColumn DataField="Amount" EmptyDataText="&amp;nbsp;" DataFormatString="{0:C}" Aggregate="Sum"

 HeaderText="Amount" UniqueName="Amount">

 <HeaderStyle Height="20px" />

 </telerik:GridBoundColumn>

 </Columns>

 </MasterTableView>

 <HeaderStyle HorizontalAlign="Center" />

 <FilterMenu EnableTheming="True">

 <CollapseAnimation Duration="200" Type="OutQuint" />

 </FilterMenu>

 </telerik:RadGrid>


Thanks,
Sentha.

 

Kostadin
Telerik team
 answered on 19 May 2014
1 answer
109 views
Hi,

I am using below javascript function to add some text in RadEditor on click of a button.

function TestFunction()
{
      var editor = $find("<%= EditorID.ClientID %>");
      editor.pasteHtml("Test");
}

I want the text to be added at the current position of cursor in editor.In chrome and mozilla it is working fine. but for IE it is adding the text at the start of editor.
Does anyone know how to resolve this problem with IE?

Nikolay
Telerik team
 answered on 19 May 2014
1 answer
157 views
I have a situation where a user uploads a file and we put that into a session variable and an imageeditor.
 protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
        {
            //Clear changes and remove uploaded image from Cache
          ImageEditor_CreateDonor.ResetChanges();
        //   Context.Cache.Remove(Session.SessionID + "UploadedFile");
            using (Stream stream = e.File.InputStream)
            {
                byte[] imgData = new byte[stream.Length];
                stream.Read(imgData, 0, imgData.Length);
                MemoryStream ms = new MemoryStream();
                ms.Write(imgData, 0, imgData.Length);

                Context.Cache.Insert(Session.SessionID + "UploadedFile", ms, null, DateTime.Now.AddMinutes(20), TimeSpan.Zero);
            }
        }

Then we put it into a image editor.
 protected void ImageEditor_CreateDonor_ImageLoading(object sender, ImageEditorLoadingEventArgs args)
        {
           
            //Handle Uploaded images
            if (!Object.Equals(Context.Cache.Get(Session.SessionID + "UploadedFile"), null))
           {
                using (EditableImage image = new EditableImage((MemoryStream)Context.Cache.Get(Session.SessionID + "UploadedFile")))
                {
                    args.Image = image.Clone();
                    args.Cancel = true;
                }
           }
        }
We the image is cropped we save the crop into the session variable.
 protected void RadImgEdt_ImageChanging(object sender, ImageEditorEventArgs e)
        {
           
            Context.Cache.Remove(Session.SessionID + "UploadedFile");
            Context.Cache.Insert(Session.SessionID + "UploadedFile", e.Image, null, DateTime.Now.AddMinutes(20), TimeSpan.Zero);
        }

Now once we save, we want to save in the db which is a byte[] format, it doesn't save correctly. (I will the comments in to show the various things I have tried.
protected void BtnDonorSave_Click(object sender, EventArgs e)
        {
            Boolean isLandingPage = false;
            string rtxtScholarshipName = this.txtScholarshipName.Text;
            string rtxtScholarshipDesc = this.txtScholarshipDesc.Text;
            byte[] fileData;


            MemoryStream file;
            EditableImage eImage;
            try
            {
                //UploadedFile file = AsyncUpload1.UploadedFiles[0];
                //fileData = new byte[file.InputStream.Length];
                //file.InputStream.Read(fileData, 0, fileData.Length);
              
                 file =
                     (MemoryStream) Context.Cache.Get(Session.SessionID + "UploadedFile");
                
                
               // UploadedFile file = AsyncUpload1.UploadedFiles[0];
               // var file = Context.Cache[(Session.SessionID + "UploadedFile")] as  MemoryStream;
                 fileData = new byte[file.Length];
                 file.Read(fileData, 0, fileData.Length);
            }

            catch (ArgumentOutOfRangeException e1)
            {
                Response.Write("<script>alert('Donor cannot be added without an image');</script>");
               
                return;
            }
       

            Int32 rcollegeId = Convert.ToInt32(this.collegeId.SelectedValue);
            string rtxtNotes = this.txtNotes.Text;
            if (chkBxNotes.Checked == true)
                isLandingPage = true;


            db.CreateDonor(rcollegeId, rtxtScholarshipName, rtxtScholarshipDesc, ReadFully(Context.Cache.Get(Session.SessionID + "UploadedFile") as MemoryStream), rtxtNotes, User.Identity.Name, DateTime.Now, isLandingPage.ToString()).Execute();
            //Response.Write("<script>alert('Donor Created');</script>");
            Session["CollDiv"] = collegeId.SelectedValue;
            Response.Redirect("DonorProfiles.aspx");
        }

So after save when I try to view the image it is a bad image.

Anyone know how to save a cropped image into a database from an imageeditor?

Thanks





Vessy
Telerik team
 answered on 19 May 2014
5 answers
109 views
Hi all,
I used Splitter Control to develop my Project. I have a problem below:
1/ When the Text is very long=> the scrollbar is shown
2/ We click on the scrollbar and drag down=> 2 splitter is drag too

I want to fix the position of the splitter.

Please view some images in attached file.


Please help me to solve it

Thanks alot 
Vessy
Telerik team
 answered on 19 May 2014
1 answer
66 views
Hi,
I need to show the fields name in my fields window with an alias. Is it possible?
My pivotgrid is populated with an object like this:

public class ReportModelObject
    {
        private string m_CompanyCode;
        private string m_CompanyDescription;
        private string m_CountryCode;
        private string m_CountryDescription;
        private string m_SiteCode;
        private string m_SiteDescription;
 
        public ReportModelObject()
        {
 
        }
 
        public string CompanyCode
        {
            get { return m_CompanyCode; }
            set { m_CompanyCode = value; NotifyPropertyChanged("CompanyCode"); }
        }
        public string CompanyDescription
        {
            get { return m_CompanyDescription; }
            set { m_CompanyDescription = value; NotifyPropertyChanged("CompanyDescription"); }
        }
        public string CountryCode
        {
            get { return m_CountryCode; }
            set { m_CountryCode = value; NotifyPropertyChanged("CountryCode"); }
        }
        public string CountryDescription
        {
            get { return m_CountryDescription; }
            set { m_CountryDescription = value; NotifyPropertyChanged("CountryDescription"); }
        }
        public string SiteCode
        {
            get { return m_SiteCode; }
            set { m_SiteCode = value; NotifyPropertyChanged("SiteCode"); }
        }
        public string SiteDescription
        {
            get { return m_SiteDescription; }
            set { m_SiteDescription = value; NotifyPropertyChanged("SiteDescription"); }
        }
         
        #region INotifyPropertyChanged Implementation
 
        [field: NonSerialized]
        public event PropertyChangedEventHandler PropertyChanged;
 
        protected void NotifyPropertyChanged(string name)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(name));
        }
 
        #endregion
         
    }
Mattia
Top achievements
Rank 2
 answered on 19 May 2014
10 answers
1.0K+ views
 

How to get Radgrid dropdown list template column selected value  in InsertCommand?


I used below, doesn't work.  Also, how to make the text filter work for a dropdownlist column?

 

 

 

DropDownList dl;

 

 

dl = newItem[

 

"Language"].Controls[0] as DropDownList;

 

 

 

 

String SelectLanguageID = dl.SelectedValue;

 

 

 

----------------------------------------------------------------
<
telerik:GridTemplateColumn HeaderText="Language" UniqueName="Language" 

 

 

 

AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"

 

 

 

ShowFilterIcon="false" FilterControlWidth="200px" >

 

 

 

 

 

 

 

 

<EditItemTemplate> 

 

 

 

<asp:DropDownList ID="ddlLanguage" runat="server"> 

 

 

 

</asp:DropDownList> 

 

 

 

</EditItemTemplate> 

 

 

 

<FooterTemplate> 

 

 

 

<asp:Label ID="lblLanguage" runat="server">

 

 

 

 

 

</asp:Label> 

 

 

 

</FooterTemplate> 

 

 

 

<ItemTemplate>

 

 

 

 

 

 

 

 

 

 

 

 

</ItemTemplate>

 

 

 

 

 

 

 

 

</telerik:GridTemplateColumn>


Thanks!

Eyup
Telerik team
 answered on 19 May 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?