Showing posts with label via. Show all posts
Showing posts with label via. Show all posts

Wednesday, March 28, 2012

Programmatically Creating TabContainer and Adding Tabs

Plan - create a TabContainer via codebehind. Then read from a SQL DB (in this case NorthWind) and use the each CategoryName as a TabPanel.

Problem - Nothing displays. However, when I place TabContainer and TabPanel controls on the page during design, then run the code, I get the tabs with Category Names, but the first tab is the default name of the one I placed on the page during design.

Thoughts/suggestions?

Forgot to add the code (DUH):

Imports AjaxControlToolkit
Imports System.Data.SqlClient
Imports System.Configuration
Partial Class _Default
Inherits System.Web.UI.Page

Dim connectionString As String = "Data Source=MATT\SQLExpress;Initial Catalog=LucaSQL;Integrated Security=True;"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Not Page.IsPostBack) Then
ReadCategories(connectionString)

End If
End Sub

Private Sub ReadCategories(ByVal connectionString As String)
Dim queryString As String = _
"SELECT CategoryID, CategoryName FROM dbo.Categories"

Using connection As New SqlConnection(connectionString)
Dim command As New SqlCommand(queryString, connection)
connection.Open()

Dim reader As SqlDataReader = command.ExecuteReader()
'Dim tc As New TabContainer

' Call Read before accessing data.
While reader.Read()
Dim CategoryName As String = reader("CategoryName")
Dim tab As New TabPanel
tab.HeaderText = CategoryName
tc.Tabs.Add(tab)

End While

' Call Close when done reading.
reader.Close()
End Using
End Sub
End Class


Hi,

In this case, you need to change its visibility with javascript. For example:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server"
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < 3; i++)
{
TabPanel tp = new TabPanel();
tp.HeaderText = "tp" + i.ToString();
tp.Controls.Add(new TextBox());
TabContainer1.Tabs.Add(tp);
}
}
</script
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function pageLoad()
{
$get("TabContainer1").style.visibility = "visible";
}
</script>

</head>
<body>
<form id="form1" runat="server">
<asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager>
<div>
<ajaxToolkit:TabContainer ID="TabContainer1" runat="server">
</ajaxToolkit:TabContainer>
<br />
<br />
<br />
<br />
</div>
</form
</body>
</html>

Programmatically Scroll GridView Control

I have an AJAX enabled web form with several data-filled GridView controls. The users accessing this web app will navigate the site via touch-screen monitors (i.e.: no mouse). As a result, I need an easy way for them to scroll the GridViews when the data is not visible. I want them to click on a button, which will then accordingly scroll the grid up or down. I have tried all the various combinations of the suggestions that I could find:

GridView.Rows(20).RowState = DataControlRowState.Selected

and

GridView.Rows(20).Focus()

and

GridView.SelectedIndex = 20

and

'Set focus to a hidden button control (column)
GridView.SelectedRow.Cells(5).Focus()

If I could set focus to a particular row, I think it should scroll to show that row. This would be fine, but nothing seems to work. Anyone have any suggestions on how I could programatically scroll a GridView control?

Thanks!

Hi AxeRose,

Did you find any solution for this problem?

I have asimilar purpose and meantime I don't have no idea, how to do this.


No, I never found a solution. I ended up using Paging instead -- which works fine for my situation.

Good luck!


I do not know if this works (and probably only in IE or in everything but IESmile ) but there is a javascript function called scrollIntoView that you could try. Just a suggestion.


Seehttp://forums.asp.net/t/1162570.aspx

You can use the JavaScript function: scrollTo(...)

-Damien


<script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_beginRequest(beginRequest);

function beginRequest()
{
prm._scrollPosition = null;
}
</script>

http://forums.asp.net/t/1156877.aspx

Monday, March 26, 2012

Programmatically trigger modal popup

I want to write a page that checks for a cookie via Javascript and then possibly opens a modal dialog box. How do I trigger the modal popup via client side javascript?

I saw the example that comes on the modal dialog that sample page, however that works with a client side event such as a click. Can I do it without listening for an event?

Hi theregit,

In the javascript where you check the cookie, you can trigger a button.

That button's click event can then be another javascript that opens a modal window.

Trigger the button like:
var myButton = document.getElementById('myButton');
myButton.click();

Is this an answer to your question?
if you have comments/remarks/questions .. please do so!

Kind regards
Wim


Try this ,

Show and Hide ModalPopupExtender from JavaScript

Hope this helps


Phanatic,

Thank you sooo much for that post. I was having the problem with the 'null' is null or not an object error. Once I used the pageLoad() method it worked great.