Showing posts with label button click. Show all posts
Showing posts with label button click. Show all posts

Tuesday, September 22, 2015

asp.net fire button click in javascript function pass parameters

1) Javascript function

 function SetDocumentEditorSrc(WrkID) {
                __doPostBack('<%= btnSetRadEditorContent.UniqueID %>', WrkID);
            }

2)  Button Click Event

        protected void btnSetRadEditorContent_Click(object sender, EventArgs e)
        {
            String fileId = Request["__EVENTARGUMENT"]; // parameter
            if (!String.IsNullOrEmpty(fileId))
            {
                String convertedContent = "";

                RxOffice.BLL.Document document = new RxOffice.BLL.Document();
                document.SetRadEditorContent(Convert.ToInt32(fileId));
                if (!String.IsNullOrEmpty(convertedContent))
                {
                    RadEditor1.Content = convertedContent;
                }
            }

            //string filePath = Server.MapPath("~/SampleInitialContent.docx");
            //byte[] fileBinaryData = File.ReadAllBytes(filePath);
            //string convertedContent = Functions.ConvertDocxToHtml(fileBinaryData);

        }

asp.net fire button click in javascript function

<asp:Button ID="btnSetRadEditorContent" runat="server" OnClick="btnSetRadEditorContent_Click" Style="display: none;" />


 function SetDocumentEditorSrc(WrkID) {
                __doPostBack('<%= btnSetRadEditorContent.UniqueID %>');
            }


  protected void btnSetRadEditorContent_Click(object sender, EventArgs e)
        {
            string filePath = Server.MapPath("~/SampleInitialContent.docx");
            byte[] fileBinaryData = File.ReadAllBytes(filePath);
            string convertedContent = Functions.ConvertDocxToHtml(fileBinaryData);

            RadEditor1.Content = convertedContent;
        }