CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Show hidden grid but with request for a PIN

Print topic Send  topic

Author Message
MarioM1977

Posts: 23
Posted: 09/14/2009, 5:36 AM

Dear Colleagues,

I did in CCS 3.2.0.2 simple page which has a record grid and two buttons to hide and show gride. The code is below:
  
<script language="JavaScript" type="text/javascript">  
function hideGrid()  
{  
document.getElementById("MyGrid").style.display = "none";  
}  
  
function showGrid()  
{  
  
//Here should be something which will ask me for a PIN to show the grid...  
//PIN can be defined somewhere inside the code  
//PIN can be not encrypted as it is only test system  
//Maybe new popup window with textbox for PIN (entered PINand two buttons:  
//<input type="button" OnClick="???" value="OK">  
//<input type="button" OnClick="???" value="Clear">  
//If PIN is ok then document.getElementById("MyGrid").style.display = "block";  
//IF PIN is not correct meesage box "PIN is not correct" or just close this popup without any message.  
// IF PIN is not correct grid will still hide.   
  
document.getElementById("MyGrid").style.display = "block";  
}  
</script>  
  
<input type="button" OnClick="hideGrid()" value="Hide">  
<input type="button" OnClick="showGrid()" value="Show">  
  
<div id="Canteen">  
  <form name="{HTMLFormName}" action="{Action}" method="post">  
  .....  
  </form>  
</div>   
  

I would like to have some security on it and ask for defined PIN when click show grid button. Grid will be shown if PIN is ok. If not, some error message. I'm newbie and having no idea how to do it. Any suggestion most welcome.

Thanks
Brgds
Mariusz
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/14/2009, 7:36 AM

As I see it, you have a few issues here.

First, if this is a popup window and the grid you are hiding/showing is in the parent window, you will have to set uo the code for the child window to pass a value indicating the correct PIN was entered so the parent window can hide/unhide you grid.

Second, unless you want the PIN to appear in the HTML code for your PIN Input screen, the popup will need to be a CCS script for doing the login and after sucessful login sends results to the parent window or the javascript will need to do a PIN check at the server using AJAX or the equivalent and upon success sent the success value to the parent window.

These are most certainly design decisions based on you overall requirements.

If you need some help with the code, Let me know/




_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/14/2009, 7:45 AM

BTW, There might be a sample AJAX type login using Modal popups in the CCS Example Pack.

In which case, it would all happen in the same window.


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
MarioM1977

Posts: 23
Posted: 09/14/2009, 8:06 AM

Quote jjrjr1:
First, if this is a popup window and the grid you are hiding/showing is in the parent window, you will have to set uo the code for the child window to pass a value indicating the correct PIN was entered so the parent window can hide/unhide you grid.

Yes, this popup window with asking for a PIN is related to the parent/main window.

Quote jjrjr1:
Second, unless you want the PIN to appear in the HTML code for your PIN Input screen, the popup will need to be a CCS script for doing the login and after sucessful login sends results to the parent window or the javascript will need to do a PIN check at the server using AJAX or the equivalent and upon success sent the success value to the parent window.

These are most certainly design decisions based on you overall requirements.

If you need some help with the code, Let me know/

I'm very beginner in programming in CCS/ASP and javascripts. I'm trying to search some example code and trying to implement in my projects. Sometimes it works, sometimes does not work. Unfortunately, in this case I need a help with the code.

Many thanks for it in advance.
Brgds
Mariusz


View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/14/2009, 8:24 AM

Sure But before we start some requirements need to be defined.

1. Will the PIN be the same for everyone?

2. Will each user of the site have a different PIN?

3. Does the site now require user logins?

4. If users login now, will this be a different that that login UserID and Password?

5. If the user selects Hide.. Will he need to enter the PIN again to Unhide?

That's all I can think of right now, but as in all good development, requirements need to be clear.

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
MarioM1977

Posts: 23
Posted: 09/14/2009, 10:53 AM

No problem, I will answer to your questions below.

Quote jjrjr1:
1. Will the PIN be the same for everyone?
Quote jjrjr1:
2. Will each user of the site have a different PIN?

This system will be used only by one person. So, the PIN will be the same.

Quote jjrjr1:
3. Does the site now require user logins?

No, it doesn't.

Quote jjrjr1:
4. If users login now, will this be a different that that login UserID and Password?

I'm not planning to use any users logins and passwords.

Quote jjrjr1:
5. If the user selects Hide.. Will he need to enter the PIN again to Unhide?

Yes, user should type a PIN to unhide the grid. This the main goal of my unsolved issue.

Quote jjrjr1:
That's all I can think of right now, but as in all good development, requirements need to be clear.

You are right :). I understand you completely. In case of any doubt just send me a question.

Thanks and regards from Poland
Mariusz
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/15/2009, 5:31 AM

Hi

Thanks for the info. That certainly makes a difference.

I am not a ASP Programmer but in CCS these concepts should be the same.

So First let's start with creating a somewhat secure and simple unlock page.

Create a new CCS page. Add 2 textboxes to the page (CCS should ask you to create a form. Select yes)

One textbox name action and in the format tab for the properties set the ID as action.
The other text box name PIN

Now add a submit button to the form with action insert, be sure to set insert OK in the properties as well.

Now select your submit button and on the properties pane for events create a custom code action for the On Click event.

Now your custom code add:

if($Container->PIN->GetValue()=="YOUR_PIN_VALUE") $Container->Action->SetValue("1");

Test this script and be sure the textbox Action gets loaded with "1" only when the correct PIN is submitted.

Once that testing is done, you can go to the format tab to the Action textbox and set type to hidden.

Now in the javascript for your new page add code that will check the value of Action and if set to 1 do what ever stuff you need to do like calling the parent's unhide function and close the child window. Basically what ever you need to do if the PIN is correct.

On the parent page change the onCLick action for the unhide button to be a window open of your new script.

This, I think, will be the easiest, quickest, and least hassle method based on your requirements.

Hope that helps.. Let me know

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/15/2009, 5:32 AM

BTW. The code above is PHP, you need to translate it to the proper syntax for ASP. Should be easy since it is very simple code.


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
MarioM1977

Posts: 23
Posted: 09/15/2009, 6:06 AM

Hi

Thanks for your suggestion/solution :-) . I will try to do it during next 2-3 days in my free time. Now I'm to busy at my regular work :(. I will let you know about the progress regarding my small project.

Thanks :-)
View profile  Send private message
MarioM1977

Posts: 23
Posted: 09/15/2009, 6:44 AM

Quote jjrjr1:
Now select your submit button and on the properties pane for events create a custom code action for the On Click event.

This custom code should be created in Server or Client part?

Brgds
Mariusz
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/15/2009, 7:04 AM

Server Side OnClick event

You will be validating the PIN server side for security


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/15/2009, 7:04 AM

That is why the code is ASP (or PHP in my example).


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
MarioM1977

Posts: 23
Posted: 09/15/2009, 8:01 AM

Quote jjrjr1:
Server Side OnClick event

You will be validating the PIN server side for security

I have already new page which is called secure.asp. There is a form NewRecord1 with two text boxes and button OK, type: submit, operation: insert.

First field has a name: TB1_Action (as action is reserverd by CCS)
Second field has a name: PIN

For button, test custom code has been created on server side on page secure_events.asp (created by CCS):
  
Function NewRecord1_Button_Insert_OnClick(Sender) 'NewRecord1_Button_Insert_OnClick @4-71B89D7A  
  
'Custom Code @8-73254650  
' -------------------------  
If CCGetParam("PIN",Empty) = "1111" THEN  
Response.Write "PIN is ok"  
Else  
Response.Write"Wrong PIN"  
End If  
  
' -------------------------  
'End Custom Code  
End Function 'Close NewRecord1_Button_Insert_OnClick @4-54C34B28  

Now if PIN is ok I get:

  
PIN is ok   
Response object error 'ASP 0156 : 80004005'   
  
Header Error   
  
/Intranet/Canteen2/Secure.asp, line 65   
  
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.   

if PIN is wrong I get:

  
Wrong PIN   
Response object error 'ASP 0156 : 80004005'   
  
Header Error   
  
/Intranet/Canteen2/Secure.asp, line 65   
  
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.   

ASP language is to difficult for me for now and I think I need more help from someone who knows ASP better than me.

Brgds


View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/15/2009, 8:25 AM

Of course. You are echoing a value from the POST method on your page. The headers have already been sent..

The example I gave you should put a "1" into the action field if the PIN is correct not echo pin is ok....

When the page is re-displayed the action field should have a 1 or nothing based on the correct pin.

You have to get that working properly before you can write the javascript code to do the unhide.

It seems you did not use any of my suggetions here. I wonder why.. Although using CCGetParam will work (and CCGetFromPost as well), Why did you not retrieve the value directly from the control? Why is you print strings instead of setting TB1_Action control to the value of 1 for a good PIN???? I am confused..

Maybe I did not make that very clear in my example.

Believe it or not the error messages you are showing me indicate the PIN check is working... You are4 getting "Headers Already Sent" because you are printing a value from your ASP code. The code you eventually wrote and showed here is working perfectly.

Do as I suggested and only set the textbox TB1_Action to 1 if PIN is OK and do nothing if not.

The field should have 1 if the PIN is Correct. blank if not. After you validate that then set that text box to hidden.

Curious what part of this you are confused about,

Let me know

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/15/2009, 8:28 AM

You do not know how to get values from fields or putr them into fields in ASP using CCS?????

That should be easy to figure out from the CCS Help...

If you want me to find it for you let me know.


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/15/2009, 8:33 AM

BTW.. The method I am proposing here for you is more basic CCS than ASP. I chose this method since it would easily translate to any language CCS supports


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/15/2009, 8:38 AM

Another way to figure it out without lookin at documentation..........

If you want to see how to put something into a control in CCS just do a test and create a retrieve value for control action fo some event. Look at how CCS codes it. Then use that as an example for your custom code here


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/21/2009, 9:11 AM

HMmmmm

Just wondering if you ever got this to work???
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
MarioM1977

Posts: 23
Posted: 09/21/2009, 9:36 AM

Quote jjrjr1:
HMmmmm

Just wondering if you ever got this to work???

Sorry for late replay :( I'm to busy at my work :( but...

everything is working fine in my small CCS project :)

Thanks for help :)

Best regards
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.