or
<telerik:RadUpload ID="imageUpload" runat="server" ControlObjectsVisibility="None" MultipleFileSelection="Disabled" AllowedFileExtensions=".jpg,.jpeg,.png,.gif" TargetFolder="~/Record/"> </telerik:RadUpload>if (imageUpload.UploadedFiles.Count>0) { // Guid guid = new Guid(); string filename = Guid.NewGuid().ToString() +imageUpload.UploadedFiles[0].GetExtension(); testimonial.FileName = filename; testimonial.FileUrl = "~/Record/" + filename; filename = Server.MapPath("~/Record/" + filename); imageUpload.UploadedFiles[0].SaveAs(filename); testimonial.FilePhysicalPath = filename; }imageUpload.UploadedFiles.Count property show 0 file upload .<input type="text" id="UserNameText" /> <br /> <input type="password" id="PasswordText" /> <br /> <input type="button" id="Login" value="Login" onclick="DoLogin();" /> <script type="text/javascript" language="javascript"> function DoLogin() { var un = document.getElementById('UserNameText').value; var pw = document.getElementById('PasswordText').value; var info = "{ 'UserName':'" + un + "', 'Password':'" + pw + "'}"; $.ajax( { type: "POST", url: "http://localhost:60876/Sitefinity/Services/Login/Login.asmx/LoginSpecial", dataType: 'json', data: info, contentType: "application/json; charset=utf-8", success: function (msg) { alert(msg.d); }, error: function (msg) { alert(msg.responseText); } }); } </script>[ScriptMethod(ResponseFormat = ResponseFormat.Json)] [WebMethod] public string LoginSpecial() { string success = String.Empty; /* read json here from jQuery POST NameValueCollection collection = request.Params;
HttpRequest request = HttpContext.Current.Request;
string json = HttpContext.Current.Request["info"] != null ? HttpContext.Current.Request["info"].ToString() : String.Empty; */ // test json string, need to read from the jquery post string json = "{ 'UserName':'test', 'Password':'test'}"; // the following two lines of code work ok with the test json string above. JavaScriptSerializer serial = new JavaScriptSerializer(); Credentials credential = (Credentials)serial.Deserialize(json, typeof(Credentials)); return "Some json message here"; }<asp:Content ID="Content1" ContentPlaceHolderID="cphBody" runat="Server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> </telerik:RadAjaxManager> <telerik:RadTextBox ID="RadTextBox1" runat="server"> </telerik:RadTextBox> <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" onneeddatasource="RadGrid1_NeedDataSource"> <ClientSettings AllowKeyboardNavigation="True"> </ClientSettings> <MasterTableView> <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings> <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <EditFormSettings> <EditColumn FilterControlAltText="Filter EditCommandColumn column"> </EditColumn> </EditFormSettings> </MasterTableView> <FilterMenu EnableImageSprites="False"> </FilterMenu> <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"> </HeaderContextMenu> </telerik:RadGrid></asp:Content>Protected Sub gvGrossPayroll_ItemCommand(ByVal sender As Object, ByVal e As GridCommandEventArgs) If e.CommandName = "UpdateAll" Then For Each editedItem As GridEditableItem In gv_grosspayroll.EditItems Dim newValues As New Hashtable() e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem) Update_PayrollRecord(editedItem.GetDataKeyValue("ID"), Convert.ToDecimal(newValues("PayrollAmount"))) Next End If gv_grosspayroll.Rebind()End Sub
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <div style="width: 500px;"> <telerik:RadGrid ID="RadGrid1" runat="server" OnInsertCommand="RadGrid1_InsertCommand" OnNeedDataSource="RadGrid1_NeedDataSource" OnUpdateCommand="RadGrid1_UpdateCommand" OnItemCommand="RadGrid1_ItemCommand"> <MasterTableView AutoGenerateColumns="false" CommandItemDisplay="Bottom"> <Columns> <telerik:GridBoundColumn UniqueName="Number" DataField="Number" HeaderText="Number"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="Title" DataField="Title" HeaderText="Title"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="Description" DataField="Description" HeaderText="Description"> </telerik:GridBoundColumn> <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"> </telerik:GridEditCommandColumn> </Columns> <EditFormSettings EditFormType="Template"> <FormTemplate> <table> <tr> <td class="textb"> Number </td> <td> <telerik:RadNumericTextBox ID="RadNumericTextBoxNumber" runat="server" Text='<%# Bind("Number") %>' NumberFormat-DecimalDigits="0" DataType="System.Int32"> </telerik:RadNumericTextBox> </td> </tr> <tr> <td class="textb"> Title </td> <td> <telerik:RadTextBox ID="RadTextBoxTitle" runat="server" MaxLength="1024" Text='<%# Bind("Title") %>'> </telerik:RadTextBox> </td> </tr> <tr> <td class="textb"> Description </td> <td> <telerik:RadTextBox ID="RadTextBoxDescription" runat="server" MaxLength="1024" TextMode="MultiLine" Text='<%# Bind("Description") %>'> </telerik:RadTextBox> </td> </tr> </table> <br /> <br /> <asp:Button CommandName="Cancel" ID="Button1" runat="server" Text="Cancel"></asp:Button> <asp:Button ID="Button2" Text="OK" runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' /> </FormTemplate> </EditFormSettings> </MasterTableView> </telerik:RadGrid> </div>protected RegistrationLine DefaultRegistrationLine() { RegistrationLine dr = new RegistrationLine(); dr = new RegistrationLine(); dr.Number = 0; dr.Title = ""; dr.Description = ""; return dr; } protected class RegistrationLine { public int Number { get; set; } public string Title { get; set; } public string Description { get; set; } } protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { tempListRegistrationLines = RadGridBindStartUpData(); } } protected static List<RegistrationLine> tempListRegistrationLines; private List<RegistrationLine> RadGridBindStartUpData() { List<RegistrationLine> list = new List<RegistrationLine>(); RegistrationLine rl; rl = new RegistrationLine(); rl.Number = 1; rl.Title = "A"; rl.Description = "aaa"; list.Add(rl); rl = new RegistrationLine(); rl.Number = 2; rl.Title = "B"; rl.Description = "bbb"; list.Add(rl); rl = new RegistrationLine(); rl.Number = 3; rl.Title = "C"; rl.Description = "ccc"; list.Add(rl); return list; } protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { RadGrid1.DataSource = tempListRegistrationLines; } protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { GridEditableItem editedItem = e.Item as GridEditableItem; List<RegistrationLine> table = tempListRegistrationLines; RegistrationLine newRow = new RegistrationLine(); RadTextBox rtb; rtb = (RadTextBox)editedItem.FindControl("RadTextBoxTitle"); newRow.Title = rtb.Text; rtb = (RadTextBox)editedItem.FindControl("RadTextBoxDescription"); newRow.Description = rtb.Text; RadNumericTextBox number = (RadNumericTextBox)editedItem.FindControl("RadNumericTextBoxNumber"); newRow.Number = number.Value.HasValue ? Convert.ToInt32(number.Value.Value) : 0; table.Add(newRow); } protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e) { GridEditableItem editedItem = e.Item as GridEditableItem; int idx = e.Item.ItemIndex; List<RegistrationLine> table = tempListRegistrationLines; table.RemoveAt(idx); RegistrationLine newRow = new RegistrationLine(); RadTextBox rtb; rtb = (RadTextBox)editedItem.FindControl("RadTextBoxTitle"); newRow.Title = rtb.Text; rtb = (RadTextBox)editedItem.FindControl("RadTextBoxDescription"); newRow.Description = rtb.Text; RadNumericTextBox number = (RadNumericTextBox)editedItem.FindControl("RadNumericTextBoxNumber"); newRow.Number = number.Value.HasValue ? Convert.ToInt32(number.Value.Value) : 0; table.Insert(idx,newRow); } protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) { string strCommand = e.CommandName; if (strCommand == RadGrid.InitInsertCommandName) { // prepare for insert: default data e.Canceled = true; RegistrationLine rl = DefaultRegistrationLine(); e.Item.OwnerTableView.InsertItem(rl); } if (strCommand == "Edit") { GridEditFormItem editItem = e.Item as GridEditFormItem; // nothing } }