Is there a function to modify string (format, bold, center) with Console.Writeline? - asp.net

I create a file with classic ASP code and it works. Now I want to apply format on my strings (bold, link for example), are there any functions to do this ?
Thanks
Dim file As New System.IO.StreamWriter("REACH.doc")
Dim title As String
title="TITLE"
'''''Here I want to apply bold on title
file.WriteLine(title)
file.Close()

Related

issue related to space after link

I am generating a link using below code
string EncryptPath = Common.Encrypt(Path);
string SourceLinkPath= string.Empty;
if (File.Exists(Server.MapPath("Image.txt")))
{
SourceLinkPath = System.IO.File.ReadAllText(Server.MapPath ("Image.txt"));
}
string link2 = SourceLinkPath + EncryptPath;
TxtPathLink2.Text = link2;
the link is generating but it is giving space after sourcepath. OUTPUT like
http://18.10.10.11/test/View.aspx?Value=
67534ERT
i want to generate like http://18.10.10.11/test/View.aspx?Value=67534ERT
How can i generate link in one line
The .txt file probably has a whitespace you are missing.
Change System.IO.File.ReadAllText(Server.MapPath ("Image.txt"))
To:
System.IO.File.ReadAllText(Server.MapPath("Image.txt")).Trim()
String.Trim() removes all leading and trailing white-space characters from the String object.

How to split a string and get all values?

So I've got this small piece of example code in my View
#{
string MyValue = "val1;val2;val3";
}
And I am wondering how I can split it where there's a semi colon, and then I can run through each value and print it in an list
Remember that in a View when using the #{} most C# code can be used. You can use this line with a loop to get what you need done.
string sub = input.Substring(0, input.indexof(";"));

Show all text of a docx in a stringBuilder with docx4j

i need to put all text of a docx in a stringBuilder, also with tab and hyphen.
i've tried the use of org.docx4j.TextUtils, but in the resultant string doesn't seen tab.
String inputfilepath = System.getProperty("user.home") + "test.docx";
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath));
MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
org.docx4j.wml.Document wmlDocumentEl = (org.docx4j.wml.Document)documentPart.getJaxbElement();
Writer out = new OutputStreamWriter(System.out);
extractText(wmlDocumentEl, out);
out.close();
As per my answer at http://www.docx4java.org/forums/docx-java-f6/is-it-possible-to-extract-all-text-also-tab-and-hyphen-t1996.html#p6933?sid=b0d58fec2ba349d0f3f49cf66411397c
The problem with tab and hyphen, as I guess you know, is that they aren't represented in the docx as normal characters.
Tab is w:tab
A hyphen might be a hyphen character, or it might be displayed (without being actually in the docx), or it might be:
http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/noBreakHyphen.html
or http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/softHyphen.html
Replicating Word's hyphenation behaviour would be a challenge.
But for the others, there are three approaches which occur to me:
generalising your traverse approach (are you using TraversalUtil.getChildrenImpl?)
doing it in XSLT (you can do this in docx4j, but XSLT is probably slower, and a mix of technologies)
marshal the main document part to a string, do suitable string replacements, then unmarshal, then use TextUtils
For (3), assuming MainDocumentPart mdp, to get it as a String:
String stringContent = mdp.getXML();
Then to inject the modified content:
mdp.setContents((Document)XmlUtils.unmarshalString(stringContent) );

How to set the values for HatchBrush from config file in asp.net?

In my class, i have used the following code
'Draw text
hb = New HatchBrush(HatchStyle.LargeConfetti, Color.LightGray, Color.DarkGray)
Now i would like to get the values assigned to HatchBrush from an xml file as follows, instead of directly assigning it in the class as above. Because there is a need to change the colors frequently.
<hatchstyle>HatchStyle.LargeGrid</hatchstyle>
<forecolor>Color.LightGray</forecolor>
<backcolor>Color.Black</backcolor>
And in my class, i have the values of all the three nodes in a string. But how do i assign these string values to my HatchBrush( _ , _ , _ ) ??
I know that these string values cannot be directly assigned to HatchBrush, but i get the values from xml as string. How do i cast it ?
Dim style As String = "LargeConfetti" ' value from xml
Dim hs As HatchStyle = DirectCast([Enum].Parse(GetType(HatchStyle), style), HatchStyle)
Dim hb = New HatchBrush(hs, Color.LightGray, Color.DarkGray)
For the colors, same method but use Color enum instead of HatchStyle.

Regular expression to convert substring to link

i need a Regular Expression to convert a a string to a link.i wrote something but it doesnt work in asp.net.i couldnt solve and i am new in Regular Expression.This function converts (bkz: string) to (bkz: show.aspx?td=string)
Dim pattern As String = "<bkz[a-z0-9$-$&-&.-.ö-öı-ış-şç-çğ-ğü-ü\s]+)>"
Dim regex As New Regex(pattern, RegexOptions.IgnoreCase)
str = regex.Replace(str, "<font color=""#CC0000"">$1</font>")
Generic remarks on your code: beside the lack of opening parentheses, you do redundant things: $-$ isn't incorrect but can be simplified into $ only. Same for accented chars.
Everybody will tell you that font tag is deprecated even in plain HTML: favor span with style attribute.
And from your question and the example in the reply, I think the expression could be something like:
\(bkz: ([a-z0-9$&.öışçğü\s]+)\)
the replace string would look like:
(bkz: <span style=""color: #C00"">$1</span>)
BUT the first $1 must be actually URL encoded.
Your regexp is in trouble because of a ')' without '('
Would:
<bkz:\s+((?:.(?!>))+?.)>
work better ?
The first group would capture what you are after.
Thanks Vonc,Now it doesnt raise error but also When i assign str to a Label.Text,i cant see the link too.Forexample after i bind str to my label,it should be viewed in view-source ;
<span id="Label1">(bkz: here)</span>
But now,it is in viewsource source;
<span id="Label1">(bkz: here)</span>

Resources