Hello,
i am working on a web application where using ASP:treeview control to display files link so that user can click and get the values into respective textboxes. my link file name format is "001193 - La Cabana - Ins Boiler and Machinery - 03-29-2023.pdf". so i have four text boxes to contain values from the link as soon as user click the link. so far i was able to manage populate three values into text boxes except Date value. For me only first two digit(03) getting not whole date. what i need to tweak to get the whole date into text box? Below is the code.
Thanks
<asp:TreeView ID="TreeView1" runat="server" _ImageSet="XPFileExplorer" NodeIndent="15" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged">
<HoverNodeStyle Font-Underline="True" ForeColor="#6666AA" />
<NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" HorizontalPadding="2px"
NodeSpacing="0px" VerticalPadding="2px"></NodeStyle>
<ParentNodeStyle Font-Bold="true" />
<SelectedNodeStyle BackColor="#B5B5B5" Font-Underline="False" HorizontalPadding="0px"
VerticalPadding="0px" />
</asp:TreeView>
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
try
{
String filename = ((System.Web.UI.WebControls.TreeView)sender).SelectedValue;
TreeNode selectedNode = TreeView1.SelectedNode;
string[] fileNameParts = selectedNode.Text.Split('-');
string projectNumber = fileNameParts[0].Trim();
string projectName = fileNameParts[1].Trim();
string insuranceType = fileNameParts[2].Trim();
string fileDate = fileNameParts[3].Trim().Replace(".pdf", "");
//string projectNumber = selectedNode.Text.Split('-')[0].Trim();
//string projectName = selectedNode.Text.Split('-')[1].Trim();
//string insuranceType = selectedNode.Text.Split('-')[2].Trim();
//string[] nodeTextparts2 = nodeTextParts[3].Split('.');
//string datePattern = @"\d{2}/\d{2}/\d{4}";
//string date = "";
//foreach (string part in nodeTextparts)
//{
// Match match = Regex.Match(part.Trim(), datePattern);
// if (match.Success)
// {
// date = match.Value;
// break;
// }
//}
//string effectiveDate = filename[3].ToString();
//string FinaleffectiveDate = nodeTextparts2[0].ToString();
String rootDirectory = AppDomain.CurrentDomain.BaseDirectory;
String relativePath = filename.Replace(rootDirectory, "");
RadPdfViewer1.PdfjsProcessingSettings.File = relativePath;
RadPdfViewer1.Visible = true;
// Fill up text boxes values from the link
rad_txtProjectNumber.Text = projectNumber;
rad_txtprojectName.Text = projectName;
rad_txtInsuranceType.Text = insuranceType;
rad_txtEffectivedate.Text = fileDate;
}
catch (Exception ex)
{
//lblerror.Text = ex.Message;
//lblerror.Visible = true;
}
}