Problem with Ajax Tabpanel selection - asp.net

I have a 2 tabpanels in my tabcontainer and both the panel has their own header text.
I have put the tabcontainer inside a table.
Above the table (OR tabcontainer) I have a label and what I am trying to do is ... changing the label text as per tab selection ... code below:
if(tabcontainer.activetabindex == 0)
{
label1.text = tabpanel1.headertext;
}
else {label1.text = tabpanel2.headertext;}
But this is not working ... even if I select the panel2 my label displays the same text as panel1 header text ... it's not changing as I want.
Am I doing anything wrong? Please help.
Thanks,
Rahul

TabContainer changes active panel without postback, so your code doesn't fire.
You have to create javascript code and call it on tabchange in browser.

Related

C# winforms DGV Add a button to a datagrid with variable text

I know how to add a button to a datagridview. What I am having a problem with is changing the text displayed based on whether a associated record exists in another table. I would like to change the text on the button to "View SR" or "Add SR" depending on if a service request exists for the record. if it even possible, how I would go about this ?
You just need to capture the exact cell and cast it in a Grid View Button Cell to adjust the value displayed. Following is a tried solution:
if (SomeTrueValue)
{
((DataGridViewButtonCell)dataGridView1.Rows[0].Cells[0]).Value = "Hello";
}
else
{
((DataGridViewButtonCell)dataGridView1.Rows[0].Cells[0]).Value = "World";
}

Disable Certain controls such as textbox, textarea, dropdowns etc when a checkbox is checked in aspx page

I need to disable the certain controls in an aspx page such as textbox, textarea, dropdown etc when a checkbox is checked. The checkbox sets a flag in the database, if the flag is set to 1, then those specific controls will be uneditable, else it will be editable.
What is the simplest and easiest way to achieve this? I am looking for concepts. Thanks in advance.
If you are retrieving data from database then you may put it in in you page load..
for example:
[this is only pseudo code]
Dim F = FlagfromDatabase;
If F = 1
txtSample.enable = false
else
txtSample.enable = true
in you checkbox event
If checkbox.check = true
set FlagInDatabase = 1
else
set FlagInDatabase = 0
load your page to execute the page load event
Try following code.
$(document).ready(function(){
$("#checkboxId").is(':checked')
{
$('input [type=text], textarea, select').css("display","none");
}
});

Clear data after submit button from text box and labels

i have a web form that asks for the mobile number and id, if the id or mobile are incorrect. the web page will display an error label, after this error label if i entered a correct information this form will be not visible anymore and a new div will be visible with another display. so here the problem is when the customer enters the new info after a wrong info, if he clicks back the label is still appearing and text box 2, i have set these elements to:
lblfailedresponce.Text = "" // 1rsst text box
txtMobilePhone.Text = "" //2nd text box
TransactionID.Text = "" // label
but it didn't work and they still appear. so what is the code in the submit button that i have to do to clear the cache or the fields from the invisible form?
Use the following code
txtMobilePhone.Text = String.Empty;
lblfailedresponce.Text = String.Empty;
<script>
$(document).ready(function() {
// clear error label if the user clicks on the text box.
$('#txtMobilePhone').click(function(){
if('#lblfailedresponce').val()!=null)
{
$('#lblfailedresponce').val()='';
}
$('#txtMobilePhone').val()='';
$('#TransactionID').val()='';
});
$('#TransactionID').click(function(){
if('#lblfailedresponce').val()!=null)
{
$('#lblfailedresponce').val()='';
}
$('#txtMobilePhone').val()='';
$('#TransactionID').val()='';
});
});
</script>
This is a script that will serve the purpose. Kindly use this at the page bottom and see how it works.Hope this will help you.
I assume the element Id of the text boxes and its name are same. Kindly change it if its otherwise.
If it is a caching issue then you could add Response.Cache.SetCacheability(HttpCacheability.NoCache) to your page load. That will make it so the browser will not cache the page.
Another option is that you could set your error label to visible=false and then make it visible in the code that checks your error. But then the next load after that the error label will not show as visible.

DropDownList Attribute not working on mouseout

I have a dropdownlist in a template field of a gridview. I am tryin to change the width of the dropdownlist is display all the values when I mouse over and then change the width back when you mouse out. Here is the code:
ddl.Attributes.Add("onmouseout", "event.srcElement.style,width = '186px';")
ddl.Attributes.Add("onmouseover", "event.srcElement.style.width = '';")
I works great when I mouse over but the mouse out doesn't change in back? am I doing something wrong?
You have a comma where a dot should be between style and width:
ddl.Attributes.Add("onmouseout", "event.srcElement.style,width = '186px';");
should be
ddl.Attributes.Add("onmouseout", "event.srcElement.style.width = '186px';");
And it probably wouldn't hurt to add semi-colons to the end of your statements.

AJAX Accordion multiple open panels

Is there a way to have two or more open panes on an AJAX accordion control? The page will default to both panes open and user can close pane if desired.
According to the AJAX Control Toolkit description page:
The Accordion is a web control that allows you to provide multiple
panes and display them one at a time
So, no is the answer to your question. You could use Collapsible Panels, which is what the Accordion control is made up of. You can have multiple instances of those visible at one time.
Use the repeater control.
Inside repeater, use accordion.
I want opposite functionality, found out this while fixing someone's code.
First, you need to use this script:
function ToggleAccordionPane(paneno) {
$find('MyAccordion_AccordionExtender')._changeSelectedIndex(-1);
if( $find('MyAccordion_AccordionExtender').get_Pane(paneno).content.style.display == "block") {
$find('MyAccordion_AccordionExtender').get_Pane(paneno).content.style.display = "none";
$find('MyAccordion_AccordionExtender')._changeSelectedIndex(paneno);
}
else {
$find('MyAccordion_AccordionExtender').get_Pane(paneno).content.style.display = "block";
}
return false;
}
Then, modify first header like this:
<Header>1. Accordion</Header>
For second and third pane:
<Header>2. AutoSize</Header>
<Header><a href="" class="accordionLink" onclick="ToggleAccordionPane(2);" >3. Control or Extender</a></Header>
Source:
http://www.c-sharpcorner.com/uploadfile/Zhenia/keeping-multiple-panes-open-in-accordion-web-control/

Resources