PDA

View Full Version : طراحی فرم سوال



project80888
یک شنبه 06 بهمن 1392, 09:54 صبح
سلام دوستان
من میخواهم یه فرم سوال طراحی کنم

جواب سوالات می تواند به صورت
Checkbox
radiobutton
textbox
fileupload
باشه
یعنی یه فرم سوال داریم که می تواند انواع سوال داخل اون باشه
الان با چه کنترلی میشه فرم طراحی کنم شاید سوال من کلی باشه ولی ممنون میشم من را راهنمائی کنید؟

Aalibeigi
یک شنبه 06 بهمن 1392, 10:20 صبح
سلام
من اگه جای شما بودم یه کمبوباکس میذاشتم تا نوع سوال رو مشخص کنه و بعدش بسته به نوع سوال شی های مورد نظر رو بهش نشون میدادن(visible کردن یا پنهان کردن)
نمیدونم جواب سوالتون رو دادم یا نه:اشتباه:
برداشت من از سوال شما این بود.

project80888
یک شنبه 06 بهمن 1392, 10:39 صبح
ببیند در واقع من یه فرم داوری مقالات می نویسم که مدیر سامانه برای ارزیابی مقالات یه فرم سوال داینامیک ایجاد می کنه این فرم داری یه سری سوال (رادیویی ، تکس باکسی ، و....) و هر سوال داری صفر تا چند جواب می باشد
یعنی سیستم کاملا داینامیک

خودم یه چیزهایی به ذهنم میرسه و دنبال یه راه حل خوب برای پیاد سازی فرم هستم

الان جداول فرم ، سوال ، جواب ایجاد کردم و کد نویسی مربوز به اضافه کردن فرم و مدیریت اون نوستم ولی توی زمینه طراحی اون نیاز به کمک دارم

project80888
یک شنبه 06 بهمن 1392, 10:40 صبح
از datalist بادی استفاده کنم برای پر کردن سوال ها و گزینه های مربوطه یا ابزار بهتری وجود داره

project80888
یک شنبه 06 بهمن 1392, 17:01 عصر
دوستان خواهشا کمکم کنید من االن تونستم فرم طراحی کنم ولی نمی دونم چه جوری اطلاعات دریافت کنم ؟




protected System.Web.UI.WebControls.Button SubmitButton;
private void ReadQuizTitle(string QuizTitle)
{


TableRow tr = new TableRow();
TableCell aCell = new TableCell();

Table1.Rows.Add(tr);
aCell.Text = "<H1><font color=\"green\">" + QuizTitle + "</font></H1>\n";
tr.Cells.Add(aCell);
}

private void FillQuestion()
{
int Formid = 4;
BL_Question obj = new BL_Question();
DataTable dtQuestion = new DataTable();
obj.BaseFormId = Formid;
obj.IsAdmin = IsAdmin;
dtQuestion = obj.SelectALLQuestionByFormID();
if (dtQuestion != null)
{
ReadQuizTitle("لطفا اطلاعات زیر را بادقت وارد کنید");
for (int NumberOfQuestions = 0; NumberOfQuestions < dtQuestion.Rows.Count; NumberOfQuestions++)
{
questionNum++;
// create a row for the question and read it from the database
TableRow tr = new TableRow();
Table1.Rows.Add(tr);
TableCell aCell = new TableCell();
// get the text for the question and stick it in the cell
aCell.Text = "<b>" + questionNum + ".</b> " + dtQuestion.Rows[NumberOfQuestions]["Question"].ToString();
tr.Cells.Add(aCell);
// add a blank row to pad between question and choices
TableRow blankRow = new TableRow();
TableCell cellPad = new TableCell();
cellPad.BorderWidth = 5;
blankRow.Cells.Add(cellPad);
Table1.Rows.Add(blankRow);

BL_Answer objAnswer = new BL_Answer();
DataTable dtAnswer = new DataTable();
objAnswer.QuestionsID_FK = dtQuestion.Rows[NumberOfQuestions]["QuestionId"].ToString().Toint32();
objAnswer.IsAdmin = IsAdmin;
dtAnswer = objAnswer.SelectALLAnswer();
if (dtAnswer != null)
{
for (int AnswerCount = 0; AnswerCount < dtAnswer.Rows.Count; AnswerCount++)
{


TableRow tr2 = new TableRow();
Table1.Rows.Add(tr2);
// create a cell for the choice
TableCell aCell3 = new TableCell();
aCell3.Width = 1000;
// align the choices on the left
aCell3.HorizontalAlign = HorizontalAlign.Left;
tr2.Cells.Add(aCell3);
// create a radio button in the cell

string typeAnswer = dtQuestion.Rows[NumberOfQuestions]["AnswerTypeId"].ToString();
switch (typeAnswer)
{
case "0":
{
CheckBox chb = new CheckBox();
chb.Text = dtAnswer.Rows[AnswerCount]["Answer"].ToString();
chb.ID = "chb" + NumberOfQuestions.ToString() + Convert.ToChar(AnswerCount + 65);
chb.Visible = true;
aCell3.Controls.Add(chb);

}
break;
case "1":
{
RadioButton rb = new RadioButton();
rb.GroupName = "rbGroup" + dtQuestion.Rows[NumberOfQuestions]["QuestionId"].ToString();
rb.Text = dtAnswer.Rows[AnswerCount]["Answer"].ToString();
rb.ID = "Radio" + NumberOfQuestions.ToString() + Convert.ToChar(AnswerCount + 65);
rb.Visible = true;
aCell3.Controls.Add(rb);

}
break;
case "2":
{
TextBox txt = new TextBox();
txt.ValidationGroup = "txtGroup" + dtQuestion.Rows[NumberOfQuestions]["QuestionId"].ToString();
txt.Text = dtAnswer.Rows[AnswerCount]["Answer"].ToString();
txt.ID = "txt" + NumberOfQuestions.ToString() + Convert.ToChar(AnswerCount + 65);
txt.Visible = true;
aCell3.Controls.Add(txt);

}

break;
case "3":
{
TextBox txt = new TextBox();
txt.TextMode = TextBoxMode.MultiLine;
txt.CssClass = "textarea";
txt.ValidationGroup = "txtGroup" + dtQuestion.Rows[NumberOfQuestions]["QuestionId"].ToString();
txt.Text = dtAnswer.Rows[AnswerCount]["Answer"].ToString();
txt.ID = "txt" + NumberOfQuestions.ToString() + Convert.ToChar(AnswerCount + 65);
txt.Visible = true;
aCell3.Controls.Add(txt);

}

break;
case "4":
{
FileUpload fi = new FileUpload();
fi.CssClass = "fileuploader";
fi.ID = "fi" + NumberOfQuestions.ToString() + Convert.ToChar(AnswerCount + 65);
fi.Visible = true;
aCell3.Controls.Add(fi);

}

break;


default:
break;
}



}
}
TableRow spacer = new TableRow();
TableCell spacerCell = new TableCell();
spacerCell.Height = 30;
spacer.Cells.Add(spacerCell);
Table1.Rows.Add(spacer); // add a spacer



}


}




}


private void AddSubmitButton()
{
SubmitButton = new Button();
this.Controls.Add(SubmitButton);
SubmitButton.Width = 100;
SubmitButton.Height = 25;
SubmitButton.Visible = true;
SubmitButton.Text = "Done";
SubmitButton.Style.Add("runat", "server");
TableRow ButtonRow = new TableRow();
TableCell ButtonCell = new TableCell();
ButtonRow.Cells.Add(ButtonCell);
ButtonCell.Controls.Add(SubmitButton);
Table1.Rows.Add(ButtonRow);
}



protected void Page_Load(object sender, EventArgs e)
{
FillQuestion();
AddSubmitButton();
}

project80888
یک شنبه 06 بهمن 1392, 17:04 عصر
فیلد AnswerTypeId من در وافع نوع سوال که به ترتیب برابر است با

0= CheckBox
1= RadioButton
2= TextBox
.....
الان نمی دونم به چه طریقی وقتی روی دکمه SubmitButton کلیک کردم اطلاعات بتونم دریافت کنم ؟

Mohammad_dn
یک شنبه 06 بهمن 1392, 17:31 عصر
به نظر شما باید به صورت داینامیک اشیا بسازید(فرم بسازید) .. توی تالار در مورد نحوه ی ساخت فرم داینامیک بحث شده

project80888
یک شنبه 06 بهمن 1392, 17:34 عصر
من کل سایت جستجو کردم میشه لینک بدید؟

ahmad156
یک شنبه 06 بهمن 1392, 18:19 عصر
http://barnamenevis.org/showthread.php?335811-%D8%A7%DB%8C%D8%AC%D8%A7%D8%AF-%D9%81%D8%B1%D9%85-%D8%AB%D8%A8%D8%AA-%D9%86%D8%A7%D9%85-%D8%A8%D8%B5%D9%88%D8%B1%D8%AA-%D8%AF%D8%A7%DB%8C%D9%86%D8%A7%D9%85%DB%8C%DA%A9&highlight=%D8%AF%D8%A7%DB%8C%D9%86%D8%A7%D9%85%DB% 8C%DA%A9