|
What events? Are the controls housed in a placeholder or panel?
Need a code snippet or some detail to move forward on this.
|
|
|
|
|
I'm converting some code from PHP to C# (.Net 2.0). Can someone that knows PHP verify that the C# code I wrote does the same thing as the original PHP code? The actual line I'm concerned about is inside the for loop.
private string HexToBin(string data)
{
int length = data.Length;
string newData = "";
for (int i = 0; i < data.Length; i += 2)
{
string value = data.Substring(i, 2);
newData += Int32.Parse(value, NumberStyles.HexNumber).ToString();
}
return newData;
}
Maybe that line in the for loop needs to be this?
newData += string.Format("{0}", Int32.Parse(value, NumberStyles.Integer));
If I completely mangled it up, don't be shy about telling me, but give me the correct code if you feel up to it.
-- modified at 11:50 Monday 24th September, 2007
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
You can't write a .NET function that does the same as that PHP code, as there are no binary strings in .NET. A PHP character is an eight bit value, while a .NET character is a 16 bit unicode character.
Binary data in .NET is usually represented as a byte array:
private byte[] HexToBin(string data) {
int length = data.Length / 2;
byte[] newData = new byte[length];
for (int i = 0; i < length; i++) {
string value = data.Substring(i * 2, 2);
newData[i] = Byte.Parse(value, NumberStyles.HexNumber);
}
return newData;
}
---
single minded; short sighted; long gone;
|
|
|
|
|
Actually - I can:
private string HexToBin
{
string newData = "";
if (data != "")
{
for (int i = 0; i < data.Length; i += 2)
{
string hexValue = data.Substring(i, 2);
string binValue = string.Format("{0}", <code>Int32</code>.Parse(hexValue, NumberStyles.AllowHexSpecifier));
newData += binValue;
}
}
return newData;
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: either of the next two lines work
That depends on what you mean by "work". They both do something, and the result is the same in both cases, but neither of them produce a result that is useful in any way.
If you have a string containing hexadecimal values, like "07FF10", that code will produce a string containing "725516". That's not a binary string as all, it's just a string containing the digits from the decimal representation of the hexadecimal values. It can't be used for anything at all, not even reproducing the hexadecimal string, as is't impossible to determine where one value ends and the next one begins.
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: That depends on what you mean by "work". They both do something, and the result is the same in both cases, but neither of them produce a result that is useful in any way.
The original question was regarding the similarity in functionality, not what the result is to be used for. So back to the original intent - does the C# version do the same thing as the PHP version?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: The original question was regarding the similarity in functionality, not what the result is to be used for. So back to the original intent - does the C# version do the same thing as the PHP version?
No, they don't, as they can't. As I explained, strings doesn't work the same in .NET as in PHP, so there is no .NET equivalent of the PHP binary string.
If you want to work with binary data in .NET you use a byte array instead.
If the binary data represents encoded text, you use one of the Encoding classes to decode the data back to a string. If the binary data for example is text encoded as UTF-8, you use the Encoding.UTF8.GetString method to decode the byte array into a string.
---
single minded; short sighted; long gone;
|
|
|
|
|
I finally got a chance to try this at home, and here's the C# version of the PHP code posted in the original message:
private string HexToBin(string data)
{
string newData = "";
if (data != "")
{
for (int i = 0; i < data.Length; i += 2)
{
string hexValue = data.Substring(i, 2);
newData += Convert.ToChar(Byte.Parse(hexValue, NumberStyles.HexNumber));
}
}
return newData;
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
That function doesn't do the same as the PHP function.
As I already explained, you need to use an Encoding class do decode the data if you want the result as a string. Now you are just taking the data and using it as unicode character codes. That only works for the characters that happen to have the same character code in unicode as they have in the encoding that was used to create the data.
---
single minded; short sighted; long gone;
|
|
|
|
|
Can anybody tell me that AOL support the calendar data api to access canlendar data of AOl in to third party website?
If yes then tell me which AOL API support that and how can i use that API.
Thank you.
Waiting for reply
Vishal Mithawala.
|
|
|
|
|
Hi..
I want to know the integration procedure of CCAvenue Payment gateway to integrate it with a ASP.NET 2.0 Shopping Cart Web Site. I am not able to see the procedure on CCAvenue's official website without beeing registered.
Can anyone provide me the solution to complete the task. I will be very thankful.
Abhishek Dubey
abhi
|
|
|
|
|
Hi,
I have problem in Fileupload, it will postback. Is there a way to prevent from posting back?
Thank you
hifiger2004
|
|
|
|
|
No. The file data is sent in the request to the server. No postback, no upload.
---
single minded; short sighted; long gone;
|
|
|
|
|
How can we control the process to execute it just only once?
Because, I have one button wherein the process will upload the excel file and at the same time will add the number of quantities into the database.
If this will be the case how can I control the process, because it will affect also on the adding of quantities, it will result to times 2 which is not correct.
hifiger2004
|
|
|
|
|
One thing you can do is, on your postback, once your code has processed the postback, in your prerender, redirect to the same URL, and put something on the query string to make the page reload it's data. This way, a refresh will not perform the postback again.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
YES!
It is working fine now. I just transfered my source code into the prerender then the result perfect, exactly as what I need.
Thank you Christ
hifiger2004
|
|
|
|
|
*grin* glad to help.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hifiger2004 wrote: Thank you Christ
I have to be satisfied with the odd '5' vote, whilst you get elevated from a plain old CodePorject staff member to the son of God in a single thread.
You can only go one higher...
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
URGENT HELP NEEDED
ERROR1: (if provider is msdaora)
Provider (0x80040E55)
Column does not exist.
ERROR 2: (if provider is OraOLEDB.oracle)
OraOLEDB (0x80040E21)
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
Hi,
i am getting above mentioned errors when i am trying to access an stored procedure in oracle 9i from an asp page. The stored procedure accepts two input variables and returns a ref cursor with result. SP is working fine if i test it at the backend.
CODE:
STORED PROCEDURE:
----------------------------------------------------------------------------------------
PROCEDURE GET_FIN_APPROVERS(p_user_id IN VARCHAR2,
p_ccc IN VARCHAR2,
o_cursor1 OUT NOCOPY REF_CURSOR)
AS
v_ccc VARCHAR2(100);
v_grade VARCHAR2(10);
BEGIN
select hou.attribute1 into v_ccc from apps.hr_all_organization_unitS hou,
apps.pay_cost_allocation_keyflex pcaf
where pcaf.COST_ALLOCATION_KEYFLEX_ID = hou.COST_ALLOCATION_KEYFLEX_ID
and pcaf.segment2 = p_ccc;
select grade into v_grade from hrr_t_emp_master
where staffnr = p_user_id and term_date is null;
xx_egpo_sro_req_pkg.get_approvers(p_user_id => p_user_id,
p_ccc => v_ccc,
p_grade => substr(v_grade,4),
o_cursor => o_cursor1 );
END GET_FIN_APPROVERS;
----------------------------------------------------------------------------------------
ASP CODE:
----------------------------------------------------------------------------------------
<%
db_CFRS = "Provider=msdaora; Data Source=erpudev; User ID=apps; Password=devapps"
SET Con = Server.CreateObject("ADODB.Connection")
Con.Open db_CFRS
Set cmdCfrsEmail= Server.CreateObject("ADODB.Command")
With cmdCfrsEmail
Set .ActiveConnection = Con
.CommandType = adCmdText
Set paramUser_Id = .CreateParameter("p_user_id", adVarChar, adParamInput, 100, "p_ccc")
.Parameters.Append paramUser_Id
Set paramCCC = .CreateParameter("p_ccc", adVarChar, adParamInput, 10, "5381")
.Parameters.Append paramCCC
SET paramOutput = .CreateParameter("o_cursor1",adVarChar,adParamOutput,5000)
.Parameters.Append paramOutput
' Resultset will fetch up to 100 actions currently. Increase if necessary
.CommandText = "{call xx_egpo_sro_req_pkg.get_fin_approvers(?,?,{resultset 100, o_cursor1})}"
'Response.Write .CommandText
Set rsCFRS =.Execute()
End With
%>
----------------------------------------------------------------------------------------
PLEASE HELP URGENTLY AS I AM NEARING DEADLINE AND THIS IS THE CHANGE REQUESTED URGENTLY.
APPRECIATE YOUR HELP IN ADVANCE
THANKS,
AZEEM QAISER
|
|
|
|
|
I sat down and started the application when I went to open a file in the projects folder... It says its gone renamed It tells me to expand the project node for more info... HELP weird stuff going on.
|
|
|
|
|
Are you new to web development?
If so, I'd suggest buying (or finding a friend that has -- i cannot suggest pirating in good conscience, but it's there) a good book on it.
Specifically, Beginning ASP.NET 2005 in C#. (or VB.NET if you prefer) Published by Apress. Between $30-40US.
http://www.amazon.com/Beginning-ASP-NET-2-0-2005-Professional/dp/1590595726/ref=sr_1_4/105-1894697-3759602?ie=UTF8&s=books&qid=1190778126&sr=8-4
In fact, I still have my series of Apress books I keep for references. They come in handy.
|
|
|
|
|
Hi everyone!
I have a html page with an IFrame; and the following code:
var doc = document.getElementById("iframe_id").contentDocument;
doc.body.innerHTML = htmlCode;
This code is run in body's onload handler. 'htmlCode' contains some (very simple) html (it is a string, of course).
I was able to test this code only in Safari 1.3 (Mac), and it didn't work
BUT: I need to test it in a Safari 2.0.4. Unfortunatelly, I don't have access to it. Anyone (with Mac) can tell me if it will work?
And why the above code didn't work with Safari 1.3? Is it possible to fix it?
Thank you very much in advance!
P.S. I understand it is a MS-centric forum, but... I do hope.
-------------------------
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
You might have better luck with writing the entire page into the iframe. Example:
var doc = document.getElementById("iframe_id").contentDocument;
doc.open();
doc.write('<html><head><title></title></head><body>'+htmlCode+'</body></html>');
doc.close();
---
single minded; short sighted; long gone;
|
|
|
|
|
Ok, this variant does work But what to do with the original code? Does it work in the Safari 2?...
Thanks anyway.
-------------------------
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
Dmitry Khudorozhkov wrote: But what to do with the original code? Does it work in the Safari 2?...
I don't know. I don't have a mac.
---
single minded; short sighted; long gone;
|
|
|
|