|
ASP.NET function:
public int withparam(int x)
{
int y;
y = x + 10;
return y;
}
HTML button
function Button1_onclick()
{
<% var st = withparam(10); %>;
document.write(st);
}
When i click on button, it says var st could not be found.
Please let me know where the syntax is wrong and is this the right way
|
|
|
|
|
you are getting this error as you have declared variable 'st' in <% %> block, means it is declared server side and you are using it at client side. so declare it at client side and assign value by calling server side method.
var st;
st = <% withparam(10) %>;
document.write(st);
|
|
|
|
|
I have applied your code.
st = <% withparam(10) %>;->It does not work.
Please let me know the solution.
|
|
|
|
|
amittinku wrote: It does not work.
what does mean by this? do u got some error or what?
|
|
|
|
|
no error as such.
It does not return anything, i mean return null.
|
|
|
|
|
Replace the line
st = <% withparam(10) %>;
with this
st = <%= withparam(10) %>;
it would work surely. i have tested it.
|
|
|
|
|
use javascript code for withparam function instead of server side code
// JScript File
function withparam(x)
{
var y = x + 10;
return y;
}
function Button1_onclick()
{
var st = withparam(10);
document.write(st);
alert(st);
}
call Button1_onclick in OnClientClick
winnie
|
|
|
|
|
Yes, the withparam is the actual function to be called, i mean if we don't need any server side processing then this way would be the best.
|
|
|
|
|
Hi
I have scenario where i am uploading some reports and some values into the database on the click of submit button event in C#.
In the submit button event i have opened the database connection, and inserted the values to the db.
Suppose as soon as i click on the submit button, if i loose the internet connection, or something else happens as that moment, the values or reports wont be updated to the db. how should i check this.
we put our code in try and catch block to catch any exception. we can throw an exception to the user in the catch block if it doesnot update the db. but before we use our "conn.open() method to open the connection to db, how to check if our request has reached the server or not? (as i told in the worst case scenario) can someone help me with this?
Thanks
KSR
|
|
|
|
|
There is no way to check this. You can prevent partial data to be inserted into database by running commands inside a transaction. So no data will be committed until you say transaction to do so.
|
|
|
|
|
A client of mine has an existing site that i am working on for them. i recently got one of the admin portals working only my client forgot his password and the old developer did not include a 'forgot password' option. I looked up the appropriate table in the database and found that the passwords are encrypted strings. i searched the sites code and is appears that the passwords are encrypted using 3DES and/or Base64. i have no clue what either of these two types of encryption are or how they work and my client needs this solved ASAP. I have attached the segment of code that processes the passwords. if someone could please help me by telling me what type of encoder i need to properly make new passwords to put in the db or even better if someone could tell me what (if any) decoder is appropriate for my strings.
the password strings (from the db):
sjC7ZhlynyK9RasULeXEQDpc5Y4=
aLOSCh1wPnjkQKDQzZOJunUSkOs=
XrqrfzuWGpwDYbhCtAB5Lc5iB8M=
0iRlJxGGzYHOiP0PgyCTCaAIf3E=
lGfiERF+kuVrO2qEoQXxROxkPxM=
065w9Cma1RivOlF5s6CluCmFjq0=
TOlL2KBYNhce2Fp7fOoS1CjDaFY=
Segment of code that encrypts password entered in form:
public static string MakeBase64CypherString(string clear)
{
return Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(Encrypt(clear)));
}
public static string DecodeBase64CypherString(string hidden)
{
return Decrypt(ASCIIEncoding.ASCII.GetString(Convert.FromBase64String(hidden)));
}
protected static string Encrypt(string clear)
{
Settings settings = Setting.AllSettings();
Setting IV = settings["IV"];
Setting Key = settings["Key"];
intelli3DESEncryption crypto = new intelli3DESEncryption("StratusRewards.RMA.BusinessServices.Application");
crypto.IV = IV.Data;
crypto.Key = Key.Data;
return crypto.EncryptStringToString(clear);
}
protected static string Decrypt(string hidden)
{
Settings settings = Setting.AllSettings();
Setting IV = settings["IV"];
Setting Key = settings["Key"];
intelli3DESEncryption crypto = new intelli3DESEncryption("StratusRewards.RMA.BusinessServices.Application");
crypto.IV = IV.Data;
crypto.Key = Key.Data;
return crypto.DecryptStringToString(hidden);
}
#endregion
|
|
|
|
|
prestonascott wrote: protected static string Decrypt(string hidden)
Have you tried passing your strings through this method ? If you have the source AND the database, have you tried just stuffing new known passwords into the DB table ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
thanks for your reply,
that is what i would do if i knew how to turn non-encrypted text (e.g. "password") into the correctly encrypted (3des) and encoded (base64) string.
example of a string in the db table:
sjC7ZhlynyK9RasULeXEQDpc5Y4=
As you can probably tell, i dont have any experience with encrypting strings
|
|
|
|
|
I'm sorry, please explain to me how the code you posted is NOT the code you need to decrypt a string, and perhaps explain in that case, why you posted it at all ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
i believe this code is what is used to encrypt text that is entered into a password box to a string that is checked against the existing strings in the database... i mainly code in php, so even applying this code to a string generating form would be a challenge for me. would it be easy for you to explain or help with this?
|
|
|
|
|
If you have no idea how to read C#, why have you taken this job ?
The obvious thing to do here, is to step through the code, with breakpoints on all these methods, and see what happens when you try to login, and when you create a new account. From there, you should be able to write a winforms app that takes passwords and decodes them, or just reset the passwords in the DB.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
well, account creation is not something that was coded into the script... i was hoping that someone would be able to help confirm the type of encryption/encoding and suggest a tool for mimicking that process.
|
|
|
|
|
"intelli3DESEncryption" is a third party component, although I thought the framework had DES encryption built in. Your best bet is ALWAYS to use the encryption/decryption code that the app uses, not some third party code that claims to impliment the same thing, what if they differ ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
There is another which not a straight forward method but workable. If he knows password of any other user then just replace the password of current user with the password of second user. Now login to the website and change password.
This technique only works if he is not using any hash uniquely to build unique password.
|
|
|
|
|
thanks for the input, hes not sure of the password though... one thing i found is that there is a web based user admin page that would allow me to edit the current passwords of the backends users. i am trying to figure out how to build a login form with a static username/pass that will allow me to access the user admin page so i can change the passes. the only problem is that i am used to php or asp and this codebehindpages and .dll stuff is confusing.
|
|
|
|
|
Hello Experts,
Following is the code not working for me .Could anyone please help me out regarding the issue?
Thanks in advance.
try
{
Response.Write("<script>window.open('http://localhost:1390/WebClient/WebPages/CommonPages/HomePage.aspx','_new','height='+screen.height+',width='+screen.width+',top=0,left=0, status=no,toolbar=no,menubar=yes,location=no,titlebar=no');</script>");
}
catch (Exception ex)
{
Response.Write(ex);
}
|
|
|
|
|
What does 'not working' mean ? What happens ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
http://..... url it doesn't open in the new page
|
|
|
|
|
But it does open ? Have you tried _blank for the target ? Have you tried with more than one browser ? Do you have any sort of popup blocker installed ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
But it does open ?
no
Have you tried _blank for the target ?
means??? is login page so if i want to open for the other page in same directory then its working.
Have you tried with more than one browser ? Do you have any sort of popup blocker installed ?
no i want to just try for IE only (ofcourse 6.0)
amit
|
|
|
|