We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Can checkbox be integrated from database in ASPOSE.Word

Hello there

I am integrating Aspose.Word in one of our application. We are using the license version of Aspose.Word. But we have checkboxes in our form whose value has to come from the database.

I want to know few things :-
1. Can Aspose.Word retrieve the value of checkbox from the database. If yes, then how…
2. Currently Aspose.Word opens the document in the same window. Can it be open in the other Window or other Tab.

I am attaching the word file along this which contains the checkboxes(whose value has to come from database).

Please help me as the site is live and i needed that urgently.

Thanks in advance…

Deepak Gupta
Team Leader
www.broadwayinfotech.com.au

Hi Deepak,

Thanks for your inquiry.

Sure, Aspose.Words can set the state of a checkbox from your database. How this is accomplished depends on the structure of your database. A sample implementation of Aspose.Words inserting checkboxes with specified state can be found here. In your case you simply just need to get the appropriate value from your database and pass it to the InsertCheckBox method or set the state of an existing form field. If you need any further clarifcation please feel free to ask.

Regarding your second question, could you please post the code you are currently using here and I will provide some further suggestions.

Thanks,

Thanks for the quick reply…

Here is the code regarding second Question :-

License license = new License();
license.SetLicense(“Aspose.Words.lic”);

Document doc = null;
string filename = “”;

if (Request.QueryString[“name”] != null)
{
filename = Globals.SetCustomTemplatePath + Request.QueryString[“name”].ToString().Trim();

// Open an existing document.
if (File.Exists(Server.MapPath("~") + filename))
doc = new Document(Server.MapPath("~") + filename);

doc.MailMerge.RemoveEmptyParagraphs = true;
// Fill the fields in the document with user data.
doc.MailMerge.Execute(dt);

doc.MailMerge.DeleteFields();

// Send the document in Word format to the client browser.
doc.Save(Globals.PDFDocumentForm, SaveFormat.Pdf, SaveType.OpenInBrowser, Response);
}


where dt returns the persistent records from database in datatable.

Hi Deepak,

Thanks for this additonal information.

I think the only way to achieve this is to use Javascript. There is a section in the Aspose.Words Web demos which does exactly this. Please take a look at the code (inside the WebForms folder where you installed Aspose.Words) under Default.aspx.cs.

The code looks like this:

if (OpenNewWindowBtn.Checked)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

PopupWindow(url);

else

Response.Redirect(url, true);

private void PopupWindow(string url)

{

string script = string.Format("", url);

ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", script);

}

Thanks,