10/30/09

Build new question Page



In this page the Admin will be able to add a new question to existing survey.  This was very complicated task for me to build this page...
I wil explain:
Those are the controls i used on the page:





The left upper control is for displaying all the options [answers] of a certain question.
The control [form] beneath is for add another option to options list.
The control at the right is for inserting the question type and text. The "insert" button of this form makes all question data [the text, type and options] being submitted to storing engine.

DOWNLOAD SOURCE

10/25/09

The application is online now!

Now you can view  and use the apllication at this URL.
everybody can play with it -create survey, edit survey and its questions, answer and view surveys

Admin

username:admin
password%6437355

10/21/09

Deploying website to remote server

Now i need to deploy all the site to remote hosting, with all pages and all database structure.
Also i want to make some users and roles so the site can be usable.
How to do it without copying the data from local to remote the database?
There is the way:
ASP.NET Config Tool


You can set the users roles and setting on remote site with ASP.NET Config Tool.
Note:When  you want ASP.NET Config Tool to work on not default aspntedb.mdf databse
you need to configure it first - How to do it? you can read this article that explains simple and clearly all about this tool.

To doing this you need only to change the connection string of providers (Rolemanager and Membership Customuized providers in web.config )

<connectionStrings>
   
 <add name="MyConnectionString"
    connectionString="Data Source=my_server;Initial   Catalog=my_DB;User my_user;Password=my_passwd;Integrated Security=False;"
     providerName="System.Data.SqlClient" />
</connectionStrings>

<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
       <providers>
          <add connectionStringName="MyConnectionString"
             name="CustomizedRoleProvider"
             type="System.Web.Security.SqlRoleProvider"
             applicationName="/M-survey1" 
             />
       </providers>
</roleManager>
<membership defaultProvider="CustomizedMembershipProvider" >
       <providers>
        
         <add connectionStringName="MyConnectionString"
               name="CustomizedMembershipProvider"
               requiresQuestionAndAnswer="false"
               type="System.Web.Security.SqlMembershipProvider"
               applicationName="/M-survey1"
              />
        
</providers>

Important!

After congifuring the users and members of the application
I found that the exisitnig usrs cannot logion and new registered users cannot access the role restricted areas.
after investigation I found that
the reason to this behavior was Appliction Name field somehow had different values for newly registered and for registered with aspNetConfiguration Tool users.


10/9/09

View Answerers Button



This button must show the list of users who answered the survey. Which survey? The one with its checkbox checked, of course :
This code is for finding which survey is checked (selected)
    private int findCheckedSurvey()
    {
        int survId = -1;
        foreach (RepeaterItem ri in Repeater1.Items)
        {
            CheckBox chkBox = (CheckBox)ri.FindControl("CheckBox1");
            if (chkBox != null && chkBox.Checked)
            {
                HiddenField hf;
                hf = (HiddenField)ri.FindControl("surveyID");
                survId = Convert.ToInt32(hf.Value);
                return survId;
            }
        }
        return survId;

    }


It means that only one survey allowed to be checked at once. How to force user not to check
more than one?
I wrote this code that unchecks the other checkboxes once user checked one of the surveys:
    protected void unCheckOthers(object sender, EventArgs e)
    {
        foreach (RepeaterItem ri in Repeater1.Items)
        {
            CheckBox chkBox = (CheckBox)ri.FindControl("CheckBox1");
            CheckBox c = (CheckBox)sender;
            bool thisIs=false;
            if (c.NamingContainer == chkBox.NamingContainer)
            {
                thisIs = true;
            }
   
           
            if (chkBox != null && chkBox.Checked && !thisIs)
            {
                chkBox.Checked = false;
            }
        }
    }

Note, that all the checkBoxes have the same ID property, so if we want the newly checked checkbox to stay checked we must use NamingContainer property which gets the unic identifier of repeater tags.
Important:If you want your checkboxes CheckedChacnged event to be handled at server code - you must set IsPostBack property to TRUE 

Getting started with docker

It is very simple to get started usig docker. All you need to do-is download the docker desktop for your system Once you get docker syste...