Have you check AutoPostBack property of dropdownlist to "true" ?
Can you please put some code here to understand it better.
protected void ddlSONo_SelectedIndexChanged(object sender, EventArgs e)
{
////if (ddlSONo.Items[0].Value == "--Choose One--")
if (this.ddlSONo.SelectedIndex == 0)
{
this.btnGenerateReport.Enabled = false;
this.btnView.Enabled = false;
}
else
{
this.btnGenerateReport.Enabled = true;
this.btnView.Enabled = true;
}
}
protected void btnGenerateReport_Click(object sender, EventArgs e)
{
////Here I have written code for report generation.
}
Hi Ritesh,
Yes I have done Autopostbackproperty true; and Here is some code.
<asp:Button ID="btnGenerateReport" runat="server" OnClick="btnGenerateReport_Click"
Style="position: relative; left: 8px; top: 18px;" Text="Generate" ValidationGroup="Report Validtion" Width="125px" />
<contenttemplate>
<asp:DropDownList ID="ddlSONo" runat="server" OnSelectedIndexChanged="ddlSONo_SelectedIndexChanged" AutoPostBack="True" Height="20px" Width="157px" TabIndex="2">
<asp:ListItem>--Choose One--</asp:ListItem>
</asp:DropDownList>
</contenttemplate>
<triggers>
<ajax:AsyncPostBackTrigger ControlID="ddlFileNo" EventName="SelectedIndexChanged"></ajax:AsyncPostBackTrigger>
</triggers>
</ajax:UpdatePanel>
protected void ddlSONo_SelectedIndexChanged(object sender, EventArgs e)
{
////if (ddlSONo.Items[0].Value == "--Choose One--")
if (this.ddlSONo.SelectedIndex == 0)
{
this.btnGenerateReport.Enabled = false;
this.btnView.Enabled = false;
}
else
{
this.btnGenerateReport.Enabled = true;
this.btnView.Enabled = true;
}
}
protected void btnGenerateReport_Click(object sender, EventArgs e)
{
////Here I have written code for report generation.
}
Place your button inside UpdatePanel also include your Report DIV or whatever tag you have used to generate report inside UpdatePanel.
Hi Ritesh,
You are telling correct thing but i am doing in my project that when i ll click the generate button it ll create another page where report will be generated, so on this case your given reply wont work .Can u give some information about my problem.
Thanks
Binod
Ok...got it. So you are opening new popup window on button click right?
Place this code on your button click after your report generation code to open popup window.
ScriptManager.RegisterStartupScript(this, typeof(string), "ReportPopup", "window.open('Report.aspx','Report', 'width=300,height=180')", true);
Hope it works, or let me know in case of any queries
Hi Ritesh,
your given code will not work please give
Any other solution plzzzz.........
Thanks
Binod
use javascript to enable/disable button
1) Place this code in page load
ddlSONo.Attributes.Add("onchange","EnableDisableButton(this);");
2) Remove AutoPostBack="True" and OnSelectedIndexChanged="ddlSONo_SelectedIndexChanged" as now we are Enabling/Disabling button through javascript.
<asp:DropDownList ID="ddlSONo" runat="server" Height="20px" Width="157px" TabIndex="2"
3) Include this javascript to enable/disable button in your page
<scriptlanguage="javascript"type="text/javascript">
functionEnableDisableButton(ddlSoNo)
{
if (ddlSoNo.selectedIndex == 0 )
document.getElementById('btnGenerateReport').disabled=true;
else
document.getElementById('btnGenerateReport').disabled=false;
}
</script
Hope it helps
Hi Ritesh
It is working. Thank u verymuch.
Binod
No comments:
Post a Comment