|
|
|
 |
 |
Исходник |
 |
|
 |
 |
|
Автор:
|
|
|
Название:
|
Исправление №1 для MaxProDataGrid2. |
|
Дата:
|
30 April 2008 |
|
Описание: |
Я улучшил работу текстбокса в нумераторе страниц. Теперь нажатие кнопки Enter приводит к применению номера страницы. Также были исправлены ошибки Яваскрипта для гэковских движков в рендере. Замените процедуры setValue() и Render() на предлагаемый здесь вариант для исправления. Предыдущий вариант находится по адресу http://aspnetmania.com/Code/Code/131.html |
| |
Разместить ссылку на этот исходник в форуме вы можете вставив в текст сообщения
следующую строку:
[CODEPOST ID=230]Исправление №1 для MaxProDataGrid2.[/CODEPOST] |
| Оценить: |
|
1 REM Заполнение значений
2 Private Sub setValue()
3 'верх
4 oTableTop = New Table
5 oTableTop.ID = "oTableTop"
6 oLabel1Top.Text = _customPager.TextFirst & " "
7 oImageButton1Top.ImageUrl = _customPager.ImageFirstUrl
8 oImageButton1Top.Attributes("onclick") = Page.GetPostBackEventReference(Me, "oImageButton1")
9 oImageButton2Top.ImageUrl = _customPager.ImageLeftUrl
10 oImageButton2Top.Attributes("onclick") = Page.GetPostBackEventReference(Me, "oImageButton2")
11 oTextBoxTop.Text = CurrentPageIndex + 1
12 oTextBoxTop.Attributes("onchange") = Page.GetPostBackEventReference(Me, "oTextBoxTop")
13 oTextBoxTop.Attributes("onkeypress") = "if(event.keyCode==13){" & Page.GetPostBackEventReference(Me, "oTextBoxTop") & ";event.returnValue=false;}"
14 oImageButton3Top.ImageUrl = _customPager.ImageRightUrl
15 oImageButton3Top.Attributes("onclick") = Page.GetPostBackEventReference(Me, "oImageButton3")
16 oImageButton4Top.ImageUrl = _customPager.ImageLastUrl
17 oImageButton4Top.Attributes("onclick") = Page.GetPostBackEventReference(Me, "oImageButton4")
18 oLabel2Top.Text = " " & _customPager.TextLast & " " & PageCount
19 Dim oCell1Top As New TableCell
20 Dim oCell2Top As New TableCell
21 Dim oCell3Top As New TableCell
22 Dim oCell4Top As New TableCell
23 Dim oCell5Top As New TableCell
24 Dim oCell6Top As New TableCell
25 Dim oCell7Top As New TableCell
26 Dim oCell8Top As New TableCell
27 oCell1Top.Style.Add("vertical-align", "middle")
28 oCell2Top.Style.Add("vertical-align", "middle")
29 oCell3Top.Style.Add("vertical-align", "middle")
30 oCell4Top.Style.Add("vertical-align", "middle")
31 oCell5Top.Style.Add("vertical-align", "middle")
32 oCell6Top.Style.Add("vertical-align", "middle")
33 oCell7Top.Style.Add("vertical-align", "middle")
34 oCell1Top.Style.Add("text-align", "center")
35 oCell2Top.Style.Add("text-align", "center")
36 oCell3Top.Style.Add("text-align", "center")
37 oCell4Top.Style.Add("text-align", "center")
38 oCell5Top.Style.Add("text-align", "center")
39 oCell6Top.Style.Add("text-align", "center")
40 oCell7Top.Style.Add("text-align", "center")
41 oCell1Top.Wrap = False
42 oCell7Top.Wrap = False
43 oCell8Top.Width = Unit.Percentage(100)
44 oCell1Top.Controls.Add(oLabel1Top)
45 oCell2Top.Controls.Add(oImageButton1Top)
46 oCell3Top.Controls.Add(oImageButton2Top)
47 oCell4Top.Controls.Add(oTextBoxTop)
48 oCell5Top.Controls.Add(oImageButton3Top)
49 oCell6Top.Controls.Add(oImageButton4Top)
50 oCell7Top.Controls.Add(oLabel2Top)
51 Dim oRowTop As New TableRow
52 oRowTop.Cells.Add(oCell1Top)
53 oRowTop.Cells.Add(oCell2Top)
54 oRowTop.Cells.Add(oCell3Top)
55 oRowTop.Cells.Add(oCell4Top)
56 oRowTop.Cells.Add(oCell5Top)
57 oRowTop.Cells.Add(oCell6Top)
58 oRowTop.Cells.Add(oCell7Top)
59 If _customPager.Width.IsEmpty And (Not Width.IsEmpty) Then oRowTop.Cells.Add(oCell8Top)
60 oTableTop.Rows.Add(oRowTop)
61 oTableTop.Width = Width
62 oTableTop.ApplyStyle(_customPager)
63 'низ
64 oTableBottom = New Table
65 oTableBottom.ID = "oTableBottom"
66 oLabel1Bottom.Text = _customPager.TextFirst & " "
67 oImageButton1Bottom.ImageUrl = _customPager.ImageFirstUrl
68 oImageButton1Bottom.Attributes("onclick") = Page.GetPostBackEventReference(Me, "oImageButton1")
69 oImageButton2Bottom.ImageUrl = _customPager.ImageLeftUrl
70 oImageButton2Bottom.Attributes("onclick") = Page.GetPostBackEventReference(Me, "oImageButton2")
71 oTextBoxBottom.Text = CurrentPageIndex + 1
72 oTextBoxBottom.Attributes("onchange") = Page.GetPostBackEventReference(Me, "oTextBoxBottom")
73 oTextBoxBottom.Attributes("onkeypress") = "if(event.keyCode==13){" & Page.GetPostBackEventReference(Me, "oTextBoxBottom") & ";event.returnValue=false;}"
74 oImageButton3Bottom.ImageUrl = _customPager.ImageRightUrl
75 oImageButton3Bottom.Attributes("onclick") = Page.GetPostBackEventReference(Me, "oImageButton3")
76 oImageButton4Bottom.ImageUrl = _customPager.ImageLastUrl
77 oImageButton4Bottom.Attributes("onclick") = Page.GetPostBackEventReference(Me, "oImageButton4")
78 oLabel2Bottom.Text = " " & _customPager.TextLast & " " & PageCount
79 Dim oCell1Bottom As New TableCell
80 Dim oCell2Bottom As New TableCell
81 Dim oCell3Bottom As New TableCell
82 Dim oCell4Bottom As New TableCell
83 Dim oCell5Bottom As New TableCell
84 Dim oCell6Bottom As New TableCell
85 Dim oCell7Bottom As New TableCell
86 Dim oCell8Bottom As New TableCell
87 oCell1Bottom.Style.Add("vertical-align", "middle")
88 oCell2Bottom.Style.Add("vertical-align", "middle")
89 oCell3Bottom.Style.Add("vertical-align", "middle")
90 oCell4Bottom.Style.Add("vertical-align", "middle")
91 oCell5Bottom.Style.Add("vertical-align", "middle")
92 oCell6Bottom.Style.Add("vertical-align", "middle")
93 oCell7Bottom.Style.Add("vertical-align", "middle")
94 oCell1Bottom.Style.Add("text-align", "center")
95 oCell2Bottom.Style.Add("text-align", "center")
96 oCell3Bottom.Style.Add("text-align", "center")
97 oCell4Bottom.Style.Add("text-align", "center")
98 oCell5Bottom.Style.Add("text-align", "center")
99 oCell6Bottom.Style.Add("text-align", "center")
100 oCell7Bottom.Style.Add("text-align", "center")
101 oCell1Bottom.Wrap = False
102 oCell7Bottom.Wrap = False
103 oCell8Bottom.Width = Unit.Percentage(100)
104 oCell1Bottom.Controls.Add(oLabel1Bottom)
105 oCell2Bottom.Controls.Add(oImageButton1Bottom)
106 oCell3Bottom.Controls.Add(oImageButton2Bottom)
107 oCell4Bottom.Controls.Add(oTextBoxBottom)
108 oCell5Bottom.Controls.Add(oImageButton3Bottom)
109 oCell6Bottom.Controls.Add(oImageButton4Bottom)
110 oCell7Bottom.Controls.Add(oLabel2Bottom)
111 Dim oRowBottom As New TableRow
112 oRowBottom.Cells.Add(oCell1Bottom)
113 oRowBottom.Cells.Add(oCell2Bottom)
114 oRowBottom.Cells.Add(oCell3Bottom)
115 oRowBottom.Cells.Add(oCell4Bottom)
116 oRowBottom.Cells.Add(oCell5Bottom)
117 oRowBottom.Cells.Add(oCell6Bottom)
118 oRowBottom.Cells.Add(oCell7Bottom)
119 If _customPager.Width.IsEmpty And (Not Width.IsEmpty) Then oRowBottom.Cells.Add(oCell8Bottom)
120 oTableBottom.Rows.Add(oRowBottom)
121 oTableBottom.Width = Width
122 oTableBottom.ApplyStyle(_customPager)
123 End Sub
124 REM Добавление строки состояния
125 Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
126 setStyle()
127 setValue()
128 Dim sBorder As String = _customPager.BorderColor.Name & " " & _customPager.BorderWidth.ToString & " " & _customPager.BorderStyle
129 If (_customPager.Visible And PagerStyle.Position = PagerPosition.Top) Or (_customPager.Visible And PagerStyle.Position = PagerPosition.TopAndBottom) Then
130 oTableTop.RenderControl(writer)
131 End If
132 MyBase.Render(writer)
133 If (_customPager.Visible And PagerStyle.Position = PagerPosition.Bottom) Or (_customPager.Visible And PagerStyle.Position = PagerPosition.TopAndBottom) Then
134 oTableBottom.RenderControl(writer)
135 End If
136 If _customPager.Width.IsEmpty Then
137 Dim sScript As String
138 Dim sFunction As String = ""
139 sScript = Chr(10)
140 sScript &= "<script language='javascript'>" & Chr(10)
141 sScript &= "<!--" & Chr(10)
142 If (_customPager.Visible And PagerStyle.Position = PagerPosition.Top) Or (_customPager.Visible And PagerStyle.Position = PagerPosition.TopAndBottom) Then
143 sScript &= " document.getElementById('" & oTableTop.ClientID & "').style.width=document.getElementById('" & ClientID & "').offsetWidth;" & Chr(10)
144 sFunction = "document.getElementById('" & oTableTop.ClientID & "').style.width=document.getElementById('" & ClientID & "').offsetWidth;"
145 End If
146 If (_customPager.Visible And PagerStyle.Position = PagerPosition.Bottom) Or (_customPager.Visible And PagerStyle.Position = PagerPosition.TopAndBottom) Then
147 sScript &= " document.getElementById('" & oTableBottom.ClientID & "').style.width=document.getElementById('" & ClientID & "').offsetWidth;" & Chr(10)
148 sFunction &= "document.getElementById('" & oTableBottom.ClientID & "').style.width=document.getElementById('" & ClientID & "').offsetWidth;"
149 End If
150 If sFunction <> "" Then
151 sScript &= " document.getElementById('" & ClientID & "').onresize=function(){" & sFunction & "};" & Chr(10)
152 End If
153 sScript &= "// -->" & Chr(10)
154 sScript &= "</script>" & Chr(10)
155 Page.RegisterStartupScript("oTable", sScript)
156 End If
157 End Sub
158 |
| Вернуться к списку исходников в категории Создание элементов управления |
|
|
 |
 |
 |
 |
|
|