ASP string format - asp.net

i was used with php to use printf to build my strings, but i cannot find anything similar with asp and i end up writing crap like:
WrapTag="<"&Tag&">"&Text&" </"&Tag&">"
instead i would liek to write something more readable, like:
WrapTag=String.Format("<{0}>{1}</{2}>",Tag,Text,Tag)
as it was shown with this url:
http://idunno.org/archive/2004/07/14/122.aspx but it is not working.
Can anyone help me on that?

The code that you show is correct.
You don't have to send in the tag name twice, you can use the same value twice in the format:
WrapTag = String.Format("<{0}>{1}</{0}>",Tag,Text)

Related

I am trying to enter a formatted chunk of code as a custom field but it never makes it to the database

I am trying to pass this into a custom field called "_vtprd_includeOrExclude"
a:2:{s:23:"includeOrExclude_option";s:11:"includeList";s:29:"includeOrExclude_checked_list";a:2:{i:0;s:2:"1856";i:1;s:4:"1857";}}
I am using WPAllImport to get the data out of an XML package and into the field.
I know that the function works because if I put "bob" in the custom field it goes in without any issue.
What is wrong with this string that is causing it to come up empty?
As always, your feedback and help is greatly appreciated.
The problem was that the data within the string would fail if turned into an array because the string count was incorrect for one of the fields.
The part to look at is at the end.
... a:2:{i:0;s:2:"1856";i:1;s:4:"1857";}}
The offender is i:0;s:2:"1856"
"1856" is 4 string characters long, not to.
So it SHOULD look like this.
i:0;s:4:"1856"
When I made that change I silenced the custom function and it worked just fine.
Perfect example of not knowing enough about how this structure works. So I guess knowing is half the battle.
go joe.

PL/SQL escape character like for statement

I've tried to search but didn't found an answer.
I've created with PL/SQL, HTML, CSS and Javascript a web application.
People can search for article and write a comment to These articles.
If they click the submit button it starts to search with the conditions of the customer.
I send the conditions as param and store them into variables.
After that I start my Statement and refresh the page with the new records.
If someone writes a comment with Special characters like
(&, %, ", ', _)
my page crashes because the Statement string isn't correct anymore.
The Statement Looks like
SELECT * FROM myTable
WHERE Name LIKE ('''%'||nameVar||'%''');
Excuse my english
Thanks
Ok, first your question about "ESCAPING" lead me to the wrong way, because you can define a "ESCAPE" character for a like Statement: This would take your % or _ in your Statement literal:
where ..... like '%\%%' ESCAPE '\'
should find a record with an % in the column.
BUT THATS NOT YOUR PROBLEM!
Your web application has to HTML encode your string - then you can store it in any database.
This has to be done by your frontend (whatever it is: ASP.NET, PHP, etc ...)
After a short Google search I found this: HTF Package, the HTF.ESCAPE_SC function encodes the string to be useable in SQL Statements.
Maybe this link helps you: https://docs.oracle.com/cd/B14099_19/web.1012/b15896/pshtp.htm

A couple ASP questions

Can anyone tell me what each of these are doing?
<%call buildBanner()%>
What I think this one is doing is calling a Method But I'm not that familiar with ASP.
Dim nInstallID : nInstallID = getParam("InstallID")
This I'm not quite sure, But from What I gathered it's a string. But I'm not sure what the ":" does or is doing.
The "call buildBanner()" is calling a function from somewhere else in your code. The function could be on the same page or it could be in an "include" file.
The ":" is just a way to separate commands on the same line. Normally you would put the two parts on two separate lines, but this is a shortcut way to use one line. Some people like to declare and initialize the variable on the same line - something you can't do in a single statement in Classic ASP.

How to remove characters before a specific character?

I want get the most specific from the current url in visual basic .net.
I've tried several code but it just was the same.
I have this code:
Dim CurrentURL1 As String = Request.Url.PathAndQuery
The code will result like: /FolderName/CurrentUrl.aspx
What I want is, just get the 'CurrentUrl.aspx'.
How to get that?
Have you tried Path.GetFilename ?
http://msdn.microsoft.com/en-us/library/system.io.path.getfilename.aspx
Actually, I think you can use the Uri class, the class is better suited for your needs. It has several properties you can use to get what you want.
http://msdn.microsoft.com/en-us/library/system.uri.aspx

pass data from parent to popup

Apologies if this seems like a duplicate post...
Thomas Warner kindly answeres an earlier post suggesting I use:
Popup.aspx?Data1=Piece_of_data&Data2=Piece_of_data
Just want to ask, if my code is Popup.aspx?Data1=textbox1.text&Data2=textbox2.text
whats the proper way to reference whats in the textboxes?
The way is is above, all that appears in the popup is the actual text 'textbox1.text'
rather than what is actualy in that control.
thanks again
Using asp.net you can litterally write the value straight into the string like:
Popup.aspx?Data1=<%=textbox1.Text%>&Data2=<%=textbox1.Text%>
A more ideal way of doing this would be to build up the URL string in your codebehind so as not to clutter up your HTML and C# code.
That way you could do something like:
String popupUrl = String.Format("Popup.aspx?Data1={0}&Data2={1}",
textbox1.Text,textbox2.Text);
This will also allow you to do any sanitization checks on the values from the textboxes before you start passing those values around.

Resources