I currently have a page that dynamically loads a user control when a button click is executed. The user control is placed on the page and loaded within a radajaxpanel. I need to run a javascript function at the completion of the user control being loaded that accesses controls within that user control. I have tried a few different ways to get this to happen, but I am unable to get it to work.
What does work is when I remove the radajaxpanel and then at the bottom of the ascx page I include the javascript function that I want to run followed by window.onload = functionToRun, but then I get the page reload etc.
I have tried to register the script at prerender, and also tried the following in the Page_PreRender of the user control to run the desired function:
System.Web.UI.
Page page = (System.Web.UI.Page)this.Page;
MasterPage mp1 = (MasterPage)page.Master;
RadAjaxManager ajm = mp1.FindControl("RadAjaxManager1") as RadAjaxManager;
string script = String.Format("functionToRun();");
ajm.ResponseScripts.Add(script);
It finds the objects it needs within the codebehind, but then cannot find the functionToRun when it is time to run the client side function.
Is there a post or article that describes the best way to run a client side function once a dynamically loaded user control has finished loading within a RadAjaxPanel?
Thank you,
Aaron
Hi,
I'm getting the "A generic error occurred in GDI+" error message while using the following code:
using (System.Drawing.Image originalImage = System.Drawing.Image.FromStream(upload.UploadedFiles[0].InputStream)) { //Create empty bitmap image of original size Bitmap tempBmp = new Bitmap(originalImage.Width, originalImage.Height); Graphics g = Graphics.FromImage(tempBmp); //draw the original image on tempBmp g.DrawImage(originalImage, 0, 0, originalImage.Width, originalImage.Height); //dispose originalImage and Graphics so the file is now free g.Dispose(); originalImage.Dispose(); Response.ContentType = "image/jpeg"; //Save the image file to original location tempBmp.Save(Server.MapPath("~Products/General/Imgs/Menus/" + parentSysName + "/" + productID.ToString() + "_" + upload.UploadedFiles[0].FileName), System.Drawing.Imaging.ImageFormat.Jpeg); }
Can you please help me how to solve this problem?
By the way, I looked on the internet, but I didn't found anything.
Regards,
Bader
[WebMethod] public RadComboBoxData GetAltIdId(RadComboBoxContext context) { string sql = "SELECT ALTID, ID FROM PEOPLE WHERE ID LIKE @text + '%'"; SqlDataAdapter adapter = new SqlDataAdapter(sql, ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); DataTable data = new DataTable(); adapter.SelectCommand.Parameters.AddWithValue("@text", context.Text); adapter.Fill(data); List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems); RadComboBoxData comboData = new RadComboBoxData(); try { int itemsPerRequest = 10; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > data.Rows.Count) { endOffset = data.Rows.Count; } if (endOffset == data.Rows.Count) { comboData.EndOfItems = true; } else { comboData.EndOfItems = false; } result = new List<RadComboBoxItemData>(endOffset - itemOffset); for (int i = itemOffset; i < endOffset; i++) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = data.Rows[i]["ID"].ToString(); itemData.Value = data.Rows[i]["ALTID"].ToString(); result.Add(itemData); } if (data.Rows.Count > 0) { comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString()); } else { comboData.Message = "No matches"; } } catch (Exception e) { //comboData.Message = e.Message; } comboData.Items = result.ToArray(); return comboData; }}-----------------------------------------------<script type="text/javascript"> function OnClientItemsRequesting(sender, eventArgs) { var context = eventArgs.get_context(); context["FilterString"] = eventArgs.get_text(); }</script><telerik:RadComboBox runat="server" ID="RadComboBox1" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged" OnClientItemsRequesting="OnClientItemsRequesting" EnableLoadOnDemand="true" ItemsPerRequest="10" ShowMoreResultsBox="True" EnableVirtualScrolling="True" Filter="Contains" EmptyMessage="Enter A#" AppendDataBoundItems="true" AutoPostBack="true"> <WebServiceSettings Method="GetAltIdId" Path="../PeopleSearch.asmx" /></telerik:RadComboBox>-------------------------------- protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) { string url = Path.GetFileName(Request.Path); url += "?HNUMBER=" + RadComboBox1.SelectedValue.ToString(); Response.Redirect(url); }"{0:dd-MMM-yyyy}".
Please suggest a solution.We are using a class file for this which is like your Demo File (CustomFilteringColumn.cs)
| ... |
| <tr> |
| <td> |
| <asp:Label ID="Label3" runat="server" Text="Search items :"></asp:Label> <asp:TextBox ID="txtSearch" runat="server" onkeyup="highlightItems();"></asp:TextBox> |
| <telerik:RadListBox ID="rlbSource" runat="server" AllowTransfer="true" CssClass="listBoxText" |
| Height="200px" SelectionMode="Multiple" TransferToID="rlbDestination" Width="450px" AllowTransferOnDoubleClick="true"> |
| <ButtonSettings ShowTransferAll="false" VerticalAlign="Middle"/> |
| <ItemTemplate> |
| <asp:Label ID="Label4" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "SYSTEM_DESCRIPTION") %>' SkinID="valuetext"></asp:Label> |
| <telerik:RadToolTip ID="RadToolTip1" runat="server" TargetControlID="Label4" RelativeTo="Element" |
| Position="BottomCenter" RenderInPageRoot="true" Width="300" CssClass="listBoxText"> |
| <b>System Particulars :</b><br /> |
| <%# DataBinder.Eval(Container.DataItem, "SYSTEM_PARTICULARS")%> |
| <br /><b>Maker :</b><br /> |
| <%# DataBinder.Eval(Container.DataItem, "MAKER")%> |
| <br /><b>City :</b><br /> |
| <%# DataBinder.Eval(Container.DataItem, "CITY")%> |
| <br /><b>Country :</b><br /> |
| <%# DataBinder.Eval(Container.DataItem, "COUNTRY")%> |
| </telerik:RadToolTip> |
| </ItemTemplate> |
| </telerik:RadListBox> |
| </td> |
| <td> |
| <telerik:RadListBox runat="server" ID="rlbDestination" Height="200px" Width="450px" |
| CssClass="listBoxText" AllowDelete="True" SelectionMode="Multiple"> |
| <ItemTemplate> |
| <asp:Label ID="Label4" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "SYSTEM_DESCRIPTION") %>' SkinID="valuetext"></asp:Label> |
| <telerik:RadToolTip ID="RadToolTip1" runat="server" TargetControlID="Label4" RelativeTo="Element" |
| Position="BottomCenter" RenderInPageRoot="true" Width="300" CssClass="listBoxText"> |
| <b>System Particulars :</b><br /> |
| <%# DataBinder.Eval(Container.DataItem, "SYSTEM_PARTICULARS")%> |
| <br /><b>Maker :</b><br /> |
| <%# DataBinder.Eval(Container.DataItem, "MAKER")%> |
| <br /><b>City :</b><br /> |
| <%# DataBinder.Eval(Container.DataItem, "CITY")%> |
| <br /><b>Country :</b><br /> |
| <%# DataBinder.Eval(Container.DataItem, "COUNTRY")%> |
| </telerik:RadToolTip> |
| </ItemTemplate> |
| </telerik:RadListBox> |
| </td> |
| </tr> |
| ... |
| if (!Page.IsPostBack) |
| { |
| rlbSource.TransferMode = ListBoxTransferMode.Copy; |
| rlbDestination.DataBind(); |
| rlbDestination.EmptyMessage = "No items added"; |
| } |
| rlbSource.DataSource = //call the function that returns a datatable. |
| rlbSource.DataValueField = "SYSTEM_CODE"; |
| rlbSource.DataTextField = "SYSTEM_DESCRIPTION"; |
| rlbSource.DataBind(); |