Showing posts with label conditions. Show all posts
Showing posts with label conditions. Show all posts

Monday, March 26, 2012

preventing the tab index change if certain conditions exist

Hello,

I have a form with a tab panel control

Tab container name (client id) : Tabs

I would like to know how to set and prevent the tab from moving from index 0 if the request.querystring("pid") is empty or null.

Here is my current javascript:

<scripttype="text/javascript">function PanelClick(sender, e) {

var mpid = gup('pid');

if (mpid=="") {

SetActiveTab("Tabs",0);

}

}

function ActiveTabChanged(sender, e) {var mpid = gup('pid');

if (mpid=="") {

alert("Please choose a page or create a new page first");

returnfalse;

}

}

function SetActiveTab(tabControl, tabNumber)

{

var ctrl = $find(tabControl);

ctrl.set_activeTab(ctrl.get_tabs()[tabNumber]);

}

function gup( name ){name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

var regexS ="[\\?&]"+name+"=([^&#]*)";

var regex =new RegExp( regexS );

var results = regex.exec( window.location.href );

if( results ==null )return"";

else

return results[1];}

</script>

I guess all I need is the javascript reference to the active tab...

can anyone help me with this?

Ok, through a little more research, I found out how to navigate or prevent navigation of the tabs control via javascript:

Here's the code

<scripttype="text/javascript">

/

function ActiveTabChanged(sender, e) {

var mpid = gup('pid'); // get the querystring in the url by calling the gup function below... good little snippet for querystrings in javascript.

var activeTab = $get("Tabs"); // gets the element by the id of "Tabs" and defines the control variable activeTab.

activeTab.value = sender.get_activeTabIndex(); // gets the active tab index of the control.

if (mpid=="" && activeTab.value!=0) { // if the conditions aren't right then don't allow the user to navigate to any other tab.

alert("Please choose a page or create a new page first"); // alert the user.

SetActiveTab("Tabs",0); // sets the active tabreturnfalse; // doesn't allow the process to go to another tab.

}

}

function SetActiveTab(tabControl, tabNumber)

{

var ctrl = $find(tabControl);

ctrl.set_activeTab(ctrl.get_tabs()[tabNumber]);

}

function gup( name ){name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

var regexS ="[\\?&]"+name+"=([^&#]*)";

var regex =new RegExp( regexS );

var results = regex.exec( window.location.href );

if( results ==null )return"";

else

return results[1];}

</script>

I hope that the scripts above can help someone else.

Wednesday, March 21, 2012

Problem In Update Panel...

Hello,

I have a Set of Buttons which are to be showed in some condition. Means Some of My buttons I want to show if User has given some conditions. So I put them in an Update Panel. Now if any button in this panel is having Server.Transfer method then it shows error and do not allow to leave that Update Panel. How to overcome this problem ? (Response.Redirect works but I have to use Server.Transfer.)

Why you need to use Server.Transfer? Can you postback to a different page?

My 2 cents about Atlashttp://alpascual.com/blog/al/archive/2006/07/18/215.aspx

http://alpascual.com/blog/al/archive/2006/07/13/207.aspx

Cheers

Al