[System.Web.Services.WebMethod]
public static string dogru(string sec, int id)
{
System.Threading.Thread.Sleep(2000);
using (Entities entities = new Entities())
{
var bak = (from v in entites.Answer where v.TrueAnswer == sec && v.SoruID == id select v).ToList();
}
}
class answer
{
public string SoruID { get; set; }
public string TrueAnswer { get; set; }
}
[System.Web.Services.WebMethod]
public static string dogru(string id1, string id2, string id3, string id4)
{
List<answer> AnswerList = new List<answer>();
for(var i=0;i<=4; i++)
{
answer answer = new answer();
answer.SoruID = i.ToString();
answer.TrueAnswer = "A";
AnswerList.Add(answer);
}
var bak = (from v in AnswerList where v.SoruID == id1 || v.SoruID == id2 || v.SoruID == id3 || v.SoruID == id4 select v).ToList();
return JsonConvert.SerializeObject(bak);
}
And the result is:
Best Regards,
Billy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
var bak = (from v in cevap where v.T_Sorular.SoruAd == id1 || v.T_Sorular.SoruAd == id2 || v.T_Sorular.SoruAd == id3 || v.T_Sorular.SoruAd == id4 select v).ToList();
It seems the T_Dogru_Cevap doesn't have T_Sorular. I think it should be:
var bak = (from v in cevap where v.SoruID== id1 || v.SoruID == id2 || v.SoruID == id3 || v.SoruID == id4 select v).ToList();
Best Regards,
Billy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
In my code, I pass SoruID to code behind and get answer back.
Does the entites.Answer has SoruID and TrueAnswer?
Please try:
var bak = (from v in entites.Answer where v.SoruID == id1 || v.SoruID == id2 || v.SoruID == id3 || v.SoruID == id4 select v).ToList();
Best Regards,
Billy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
I did likw below, but How can we do TrueAnswer = drpCevap1 and drpCevap2 and drpCevap3 and drpCevap4 dynamic. And if true answer textbox green.
using (Entities enties = new Entities())
{
List<T_Dogru_Cevap> cevap = new List<T_Dogru_Cevap>();
for (int i = 13; i <= 16; i++)
{
T_Dogru_Cevap cvp = new T_Dogru_Cevap();
cvp.SoruID = i;
//cvp.DogruCevap = id1;
cevap.Add(cvp);
}
var bak = (from v in entites.T_Dogru_Cevap where v.T_Sorular.SoruAd == id1 || v.T_Sorular.SoruAd == id2 || v.T_Sorular.SoruAd == id3 || v.T_Sorular.SoruAd == id4 select v).ToList();
return "";
}
class answer
{
public string SoruID { get; set; }
public string TrueAnswer { get; set; }
}
var bak = (from v in entites.T_Dogru_Cevap
where v.T_Sorular.SoruAd == id1 || v.T_Sorular.SoruAd == id2 || v.T_Sorular.SoruAd == id3 || v.T_Sorular.SoruAd == id4
select new answer{
SoruID =v.T_Sorular.SoruAd,
TrueAnswer = v.TrueAnswer
}).ToList();
return bak;
Best Regards,
Billy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Could you post your all code? The aspx and T_Dogru_Cevap?
Best Regards,
Billy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
What's in the T_Dogru_Cevap and how do you bind data to the ddl? What's the text and value in the ddl?
Best Regards,
Billy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
private void GetVeri()
{
drpBaslik.DataSource = wired.T_Wired_Icerik.ToList();
drpBaslik.DataTextField = "BaslikAd";
drpBaslik.DataValueField = "ID";
drpBaslik.DataBind();
drpBaslik.Items.Insert(0, new ListItem("Seçiniz", "0"));
}
protected void drpBaslik_SelectedIndexChanged(object sender, EventArgs e)
{
int id = Convert.ToInt32(drpBaslik.SelectedItem.Value);
var cek = (from v in wired.T_Wired_Icerik where v.BaslikAd == drpBaslik.SelectedItem.Text select v).FirstOrDefault();
var soru = (from v in wired.T_Sorular where v.TWID == id select v).ToList();
txtIcerik.Text = cek.Yazi;
int i = 1;
foreach (var item in soru)
{
if (i == 1)
{
var cevap = (from v in wired.T_Dogru_Cevap where v.SoruID == item.ID select v).FirstOrDefault();
txtSoru1.Text = item.SoruAd;
txtCevap1.Text = cevap.Cevap1;
txtCevap2.Text = cevap.Cevap2;
txtCevap3.Text = cevap.Cevap3;
txtCevap4.Text = cevap.Cevap4;
drpCevap1.Items.Insert(0, new ListItem(txtCevap1.Text, txtCevap1.Text));
drpCevap1.Items.Insert(0, new ListItem(txtCevap2.Text, txtCevap2.Text));
drpCevap1.Items.Insert(0, new ListItem(txtCevap3.Text, txtCevap3.Text));
drpCevap1.Items.Insert(0, new ListItem(txtCevap4.Text, txtCevap4.Text));
drpCevap1.Items.Insert(0, new ListItem("Seçiniz..", "0"));
}
else if (i == 2)
{
var cevap = (from v in wired.T_Dogru_Cevap where v.SoruID == item.ID select v).FirstOrDefault();
txtSoru2.Text = item.SoruAd;
txtCevap5.Text = cevap.Cevap1;
txtCevap6.Text = cevap.Cevap2;
txtCevap7.Text = cevap.Cevap3;
txtCevap8.Text = cevap.Cevap4;
drpCevap2.Items.Insert(0, new ListItem(txtCevap5.Text, txtCevap5.Text));
drpCevap2.Items.Insert(0, new ListItem(txtCevap6.Text, txtCevap6.Text));
drpCevap2.Items.Insert(0, new ListItem(txtCevap7.Text, txtCevap7.Text));
drpCevap2.Items.Insert(0, new ListItem(txtCevap8.Text, txtCevap8.Text));
drpCevap2.Items.Insert(0, new ListItem("Seçiniz..", "0"));
}
else if (i == 3)
{
var cevap = (from v in wired.T_Dogru_Cevap where v.SoruID == item.ID select v).FirstOrDefault();
txtSoru3.Text = item.SoruAd;
txtCevap9.Text = cevap.Cevap1;
txtCevap10.Text = cevap.Cevap2;
txtCevap11.Text = cevap.Cevap3;
txtCevap12.Text = cevap.Cevap4;
drpCevap3.Items.Insert(0, new ListItem(txtCevap9.Text, txtCevap9.Text));
drpCevap3.Items.Insert(0, new ListItem(txtCevap10.Text,txtCevap10.Text));
drpCevap3.Items.Insert(0, new ListItem(txtCevap11.Text,txtCevap11.Text));
drpCevap3.Items.Insert(0, new ListItem(txtCevap12.Text, txtCevap12.Text));
drpCevap3.Items.Insert(0, new ListItem("Seçiniz..", "0"));
}
else if (i == 4)
{
var cevap = (from v in wired.T_Dogru_Cevap where v.SoruID == item.ID select v).FirstOrDefault();
txtSoru4.Text = item.SoruAd;
txtCevap13.Text = cevap.Cevap1;
txtCevap14.Text = cevap.Cevap2;
txtCevap15.Text = cevap.Cevap3;
txtCevap16.Text = cevap.Cevap4;
drpCevap4.Items.Insert(0, new ListItem(txtCevap13.Text, txtCevap13.Text));
drpCevap4.Items.Insert(0, new ListItem(txtCevap14.Text, txtCevap14.Text));
drpCevap4.Items.Insert(0, new ListItem(txtCevap15.Text, txtCevap15.Text));
drpCevap4.Items.Insert(0, new ListItem(txtCevap16.Text, txtCevap16.Text));
drpCevap4.Items.Insert(0, new ListItem("Seçiniz..", "0"));
}
i++;
}
}
As I said in my previous post, please set your ddl's text to the answer, the value to the textbox's Id.
For example:
drpCevap1.Items.Insert(0, new ListItem(txtCevap1.Text, txtCevap1.ID));
And the id1, id2, id3, id4 is SoruId:
var bak = (from v in wireds.T_Dogru_Cevap
where v.SoruId == id1 || v.SoruId == id2 || v.SoruId == id3 || v.SoruId == id4
select new
{
SoruID = v.SoruID,
DogruCevap = v.DogruCevap
}).ToList();
Best Regards,
Billy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Do you get any error message in browser develop tool (F12)?
And you could set a breakpoint in behind code to check whether the method is fired.
Best Regards,
Billy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
But I need to when I click button after which txtCevap1,txtCevap2,txtCevap3txt,Cevap4, true border green or border red.
Need to txtCevap loop.
Sorry, I do not understand what do you want, could you describe it?
Best Regards,
Billy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Do you mean only the true answer's textbox border will change color?
If so, please try to use the folloing code:
success: function (msg) {
var data = $.parseJSON(msg.d);
for (var i = 1; i <= 4; i++) {
for (var j = 0; j < 4; j++) {
if ($('input[id$=txtSoru'+ i +']').val() == data[j].SoruID) {
var option = $('#drpCevap' + i +" option" );
for (var k = 0; k < 4; k++) {
if ($(option[k]).text() == data[j].TrueAnswer) {
if (option[k].selected) {
$("#" + $(option[k]).val()).css('border-color', 'green');
} else {
$("#" + $(option[k]).val()).css('border-color', 'Red');
}
}
}
}
}
}
},
Best Regards,
Billy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Your code not working. Like below code we can do. Below code each txtCevap according to SoruID if true green if not true red.
For example : DropDown selected value if the answer you chose to match the answer options to the question about the selected value will be green if it is correct and red if it is not.
$.each(data, function () {
var soru = $('#txtSoru1').val().trim();
var cvp = $('#drpCevap1 :selected').text().trim();
var dcvp = $('#txtCevap');
if (soru == this.SoruID) {
if (cvp == this.DogruCevap)
{
dcvp.addClass("dog");
}
else
{
dcvp.addClass("yan");
}
}
})
Member
21 Points
240 Posts
Click Button Question and Answer True Answer With Ajax
Nov 05, 2017 10:19 PM|Aliyilmaz|LINK
Hi I have 4 questions and I have 4 answers. If the selected answer is correct, TextBox will be green. If it is wrong, it will be red.
How can I do this.
Html
Code Behind
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari
Participant
1778 Points
838 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 06, 2017 06:28 AM|TechView|LINK
Hello Aliyilmaz! Go these links and surely, you'll get the answers here:
http://dailydotnettips.com/2011/03/12/change-textbox-style-with-dropdownlist-value-change-in-asp-net-using-jquery/
https://forums.asp.net/t/1372922.aspx?disable+grey+out+a+textbox+based+on+the+selection+made+in+a+dropdownlist
TechView
Contributor
2230 Points
815 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 06, 2017 06:41 AM|Billy Liu|LINK
Hi Aliyilmaz,
I think you could try to set the ddl's value to the id of the textboxes and the text to the answer.
And pass the id of question to the code behind, and return the true answer.
For example:
<table> <thead> <tr> <td>Başlık : <asp:DropDownList ID="drpBaslik" OnSelectedIndexChanged="drpBaslik_SelectedIndexChanged" AutoPostBack="true" runat="server"> <asp:ListItem>Seçiniz</asp:ListItem> </asp:DropDownList> </td> </tr> </thead> <tbody> <tr> <td>İçerik : <asp:TextBox ID="txtIcerik" Width="587px" TextMode="MultiLine" Rows="3" runat="server"></asp:TextBox> <br /> </td> </tr> </tbody> </table> <h2 style="width: 800px; text-align: center">Sorular </h2> <h4 style="color: red;">Soru 1 </h4> <table> <thead> </thead> <tbody> <tr> <td> <asp:TextBox ID="txtSoru1" placeholder="Soru Adı" Width="500px" runat="server"></asp:TextBox> </td> </tr> <tr> <td> <asp:TextBox ID="txtCevap1" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> <td> <asp:TextBox ID="txtCevap2" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> </tr> <tr> <td> <asp:TextBox ID="txtCevap3" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> <td> <asp:TextBox ID="txtCevap4" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> </tr> <tr> <td style="text-align: center">Cevap : <asp:DropDownList ID="drpCevap1" runat="server"> <asp:ListItem Text="A" Value="txtCevap1"></asp:ListItem> <asp:ListItem Text="B" Value="txtCevap2"></asp:ListItem> <asp:ListItem Text="C" Value="txtCevap3"></asp:ListItem> <asp:ListItem Text="D" Value="txtCevap4"></asp:ListItem> </asp:DropDownList> </td> </tr> </tbody> </table> <h4 style="color: red;">Soru 2 </h4> <table> <thead> </thead> <tbody> <tr> <td> <asp:TextBox ID="txtSoru2" placeholder="Soru Adı" Width="500px" runat="server"></asp:TextBox> </td> </tr> <tr> <td> <asp:TextBox ID="txtCevap5" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> <td> <asp:TextBox ID="txtCevap6" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> </tr> <tr> <td> <asp:TextBox ID="txtCevap7" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> <td> <asp:TextBox ID="txtCevap8" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> </tr> <tr> <td style="text-align: center">Cevap : <asp:DropDownList ID="drpCevap2" runat="server"> <asp:ListItem Text="A" Value="txtCevap5"></asp:ListItem> <asp:ListItem Text="B" Value="txtCevap6"></asp:ListItem> <asp:ListItem Text="C" Value="txtCevap7"></asp:ListItem> <asp:ListItem Text="D" Value="txtCevap8"></asp:ListItem> </asp:DropDownList> </td> </tr> </tbody> </table> <h4 style="color: red;">Soru 3 </h4> <table> <thead> </thead> <tbody> <tr> <td> <asp:TextBox ID="txtSoru3" placeholder="Soru Adı" Width="500px" runat="server"></asp:TextBox> </td> </tr> <tr> <td> <asp:TextBox ID="txtCevap9" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> <td> <asp:TextBox ID="txtCevap10" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> </tr> <tr> <td> <asp:TextBox ID="txtCevap11" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> <td> <asp:TextBox ID="txtCevap12" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> </tr> <tr> <td style="text-align: center">Cevap : <asp:DropDownList ID="drpCevap3" runat="server"> <asp:ListItem Text="A" Value="txtCevap9"></asp:ListItem> <asp:ListItem Text="B" Value="txtCevap10"></asp:ListItem> <asp:ListItem Text="C" Value="txtCevap11"></asp:ListItem> <asp:ListItem Text="D" Value="txtCevap12"></asp:ListItem> </asp:DropDownList> </td> </tr> </tbody> </table> <h4 style="color: red;">Soru 4 </h4> <table> <thead> </thead> <tbody> <tr> <td> <asp:TextBox ID="txtSoru4" placeholder="Soru Adı" Width="500px" runat="server"></asp:TextBox> </td> </tr> <tr> <td> <asp:TextBox ID="txtCevap13" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> <td> <asp:TextBox ID="txtCevap14" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> </tr> <tr> <td> <asp:TextBox ID="txtCevap15" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> <td> <asp:TextBox ID="txtCevap16" placeholder="Soru Cevap" Width="500px" runat="server"></asp:TextBox> </td> </tr> <tr> <td style="text-align: center">Cevap : <asp:DropDownList ID="drpCevap4" runat="server"> <asp:ListItem Text="A" Value="txtCevap13"></asp:ListItem> <asp:ListItem Text="B" Value="txtCevap14"></asp:ListItem> <asp:ListItem Text="C" Value="txtCevap15"></asp:ListItem> <asp:ListItem Text="D" Value="txtCevap16"></asp:ListItem> </asp:DropDownList> </td> </tr> </tbody> </table> <table> <thead> </thead> <tbody> <tr> <input id="btnTamamla" type="button" value="Sınav Tamamla" /> </tr> </tbody> </table> <script type="text/javascript"> $(document).ready(function () { $("#btnTamamla").click(function () { $.ajax({ type: "POST", url: "Case-ClickButtonQuestionandAnswerTrueAnswerWithAjax.aspx/dogru", data: "{ 'id1': '" + $('input[id$=txtSoru1]').val() + "', 'id2': '" + $('input[id$=txtSoru2]').val() + "', 'id3': '" + $('input[id$=txtSoru3]').val() + "', 'id4': '" + $('input[id$=txtSoru4]').val() + "' }", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { var data = $.parseJSON(msg.d); for (var i = 1; i <= 4; i++) { for (var j = 0; j < 4; j++) { if ($('input[id$=txtSoru'+ i +']').val() == data[j].SoruID) { var id = $('#drpCevap' + i + ' :selected').val(); if ($('#drpCevap' + i + ' :selected').text() == data[j].TrueAnswer) { $("#" + id).css('border-color', 'green'); } else { $("#" + id).css('border-color', 'red'); } } } } }, error: function () { if (txtemail.value == "") { alert('Boş alan bırakmayın..'); $('#ajaxloading').hide(); } else { alert('Talep esnasında sorun oluştu. Yeniden deneyin'); $('#ajaxloading').hide(); } } }); }); }); </script>
In Code Behind:
And the result is:
Best Regards,
Billy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
21 Points
240 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 06, 2017 09:37 AM|Aliyilmaz|LINK
Thank you Billy Liu,
But I dont understand some your code.
I selected dropdowns selected Item Value.
drpCevap1
drpCevap2
drpCevap3
drpCevap4
Also Soru ID int parameters string. I get error.
I get error below code. Null Exception
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari
Contributor
2230 Points
815 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 06, 2017 11:06 AM|Billy Liu|LINK
Hi Aliyilmaz,
It seems the T_Dogru_Cevap doesn't have T_Sorular. I think it should be:
Best Regards,
Billy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
21 Points
240 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 06, 2017 11:11 AM|Aliyilmaz|LINK
Hi Billy Liu,
Yes T_Sorular.SoruAd == id1 null execption. Also I try to selected dropdown selected after if true textbox green. How can I do with your code.
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari
Contributor
2230 Points
815 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 06, 2017 11:26 AM|Billy Liu|LINK
Hi Aliyilmaz,
In my code, I pass SoruID to code behind and get answer back.
Does the entites.Answer has SoruID and TrueAnswer?
Please try:
Best Regards,
Billy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
21 Points
240 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 06, 2017 11:38 AM|Aliyilmaz|LINK
Hi Billy Liu,
I did likw below, but How can we do TrueAnswer = drpCevap1 and drpCevap2 and drpCevap3 and drpCevap4 dynamic. And if true answer textbox green.
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari
Contributor
2230 Points
815 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 06, 2017 11:51 AM|Billy Liu|LINK
Hi Aliyilmaz,
What is T_Dogru_Cevap?
Does it contains the QuestionId and answer?
If so, please try something like:
Best Regards,
Billy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
21 Points
240 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 06, 2017 12:04 PM|Aliyilmaz|LINK
Hi Billy Liu,
I have two tables. T_dogru_Cevap so True Answer and Question. True Answer and Question between relation.
I try like below. But now if true answer txtCevap1 green will be. or txtCevap2 red. Now not working.
Code Behind,
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari
Contributor
2230 Points
815 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 07, 2017 01:30 AM|Billy Liu|LINK
Hi Aliyilmaz,
Could you post your all code? The aspx and T_Dogru_Cevap?
Best Regards,
Billy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
21 Points
240 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 07, 2017 09:23 AM|Aliyilmaz|LINK
Hi Billy Liu,
Html
Ajax,
Code Behind,
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari
Contributor
2230 Points
815 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 07, 2017 09:28 AM|Billy Liu|LINK
Hi Aliyilmaz,
Do you only have these code in your code behind?
What's in the T_Dogru_Cevap and how do you bind data to the ddl? What's the text and value in the ddl?
Best Regards,
Billy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
21 Points
240 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 07, 2017 09:42 AM|Aliyilmaz|LINK
Hi Billy Liu,
Html and cod behind,
T_Dogru_Cevap table name. Like below
T_Sorular Table name
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari
Member
21 Points
240 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 07, 2017 12:06 PM|Aliyilmaz|LINK
Hi Billy Liu,
I post all code. Do you try example ?
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari
Contributor
2230 Points
815 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 07, 2017 12:21 PM|Billy Liu|LINK
Hi Aliyilmaz,
As I said in my previous post, please set your ddl's text to the answer, the value to the textbox's Id.
For example:
And the id1, id2, id3, id4 is SoruId:
Best Regards,
Billy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
21 Points
240 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 07, 2017 12:39 PM|Aliyilmaz|LINK
Hi billy Liu,
I try this but dont do that. Below code only get Ask and Answer. But Ajax dont working.
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari
Contributor
2230 Points
815 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 07, 2017 12:44 PM|Billy Liu|LINK
Hi Aliyilmaz,
Do you get any error message in browser develop tool (F12)?
And you could set a breakpoint in behind code to check whether the method is fired.
Best Regards,
Billy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
21 Points
240 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 07, 2017 12:56 PM|Aliyilmaz|LINK
I dont get any error. But not get true response.
I did try like below. Working error function showing alert. But write "undfined".
Ajax.
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari
Member
21 Points
240 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 07, 2017 02:12 PM|Aliyilmaz|LINK
Hi Billy Liu,
I shared all my code. But still dont solved problem. Why ?
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari
Member
21 Points
240 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 07, 2017 07:05 PM|Aliyilmaz|LINK
Hi Billy Liu,
I am trying like below, But dont class add textbox. One second show red or green after remove red or green. Why ?
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari
Contributor
2230 Points
815 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 08, 2017 01:23 AM|Billy Liu|LINK
Hi Aliyilmaz,
Because you are using an asp.net button. When you click it, it will postback, and cause the page refresh.
Please check my first post, use an HTML button:
Best Regards,
Billy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
21 Points
240 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 08, 2017 09:07 AM|Aliyilmaz|LINK
Hi Billy Ziu,
I solver this problem.
But I need to when I click button after which txtCevap1,txtCevap2,txtCevap3txt,Cevap4, true border green or border red.
Need to txtCevap loop.
How can I do.
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari
Contributor
2230 Points
815 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 08, 2017 09:33 AM|Billy Liu|LINK
Hi Aliyilmaz,
Sorry, I do not understand what do you want, could you describe it?
Best Regards,
Billy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
21 Points
240 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 08, 2017 09:40 AM|Aliyilmaz|LINK
Hi Billy Liu,
Sorry I didnt tell you. The texboxes they will not all burn. Only the right answer will burn.
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari
Contributor
2230 Points
815 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 08, 2017 12:19 PM|Billy Liu|LINK
Hi Aliyilmaz,
Do you mean only the true answer's textbox border will change color?
If so, please try to use the folloing code:
Best Regards,
Billy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
21 Points
240 Posts
Re: Click Button Question and Answer True Answer With Ajax
Nov 08, 2017 01:07 PM|Aliyilmaz|LINK
Hi Billy Liu,
Your code not working. Like below code we can do. Below code each txtCevap according to SoruID if true green if not true red.
For example : DropDown selected value if the answer you chose to match the answer options to the question about the selected value will be green if it is correct and red if it is not.
https://www.portakalahsap.com
https://www.portakalahsap.com/ofis-mobilyalari