1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
Imports System.Data.SqlClient Imports System.Data ... Dim con As New SqlConnection Dim cmd As New SqlCommand Try With con .ConnectionString = ConfigurationManager.ConnectionStrings("dbConnectionString").ConnectionString .Open() End With With cmd .Connection = con .CommandText = "StoredProcedureName" .CommandType = CommandType.StoredProcedure .Parameters.Add("@ParamA", SqlDbType.NVarChar, 0).Value = "..." .Parameters.Add("@ParamB", SqlDbType.Int).Value = 1 .ExecuteNonQuery() End With Catch ex As Exception ' обработка ошибок Finally cmd.Dispose() con.Close() End Try |
Monthly Archives: June 2013
301 Moved Permanently в ASP.NET и ASP
Следующий код создаёт SEO-дружственный редирект в ASP.NET
1 2 3 |
' Для версий ASP.NET < 4.0 Response.Status = "301 Moved Permanently" Response.AddHeader("Location", NewUrl) |
1 2 |
' Для версий ASP.NET 4.0 и 4.5 HttpResponse.RedirectPermanent(NewUrl) |
1 2 3 |
' Для классического ASP Response.Status = "301 Moved Permanently"; Response.AddHeader("Location", NewUrl); |
Чтение случайной строки в SQL Server
1 |
SELECT TOP 1 Column FROM Table ORDER BY NEWID() |
Динамическое добавления обработчика событий для объектов внутри Repeater
Этот код динамически добавляет процедуру MyEventHandler в виде обработчика события CheckedChanged для всех чекбоксов MyCheckBox находящихся внутри объекта Repeater.
1 2 3 4 5 6 |
' Фрагмент .ASPX файла: <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"> <ItemTemplate> <asp:CheckBox ID="MyCheckBox" runat="server" AutoPostBack="true" /> </ItemTemplate> </asp:Repeater> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
' Фрагмент .VB файла: Protected Sub Repeater1_ItemCreated(sender As Object, e As RepeaterItemEventArgs) Handles Repeater1.ItemCreated Dim ri As RepeaterItem = DirectCast(e.Item, RepeaterItem) If ri.ItemType = ListItemType.Item OrElse ri.ItemType = ListItemType.AlternatingItem Then Dim cb As CheckBox = TryCast(ri.FindControl("MyCheckBox"), CheckBox) AddHandler cb.CheckedChanged, AddressOf myEventHandler End If End Sub Protected Sub MyEventHandler(sender As Object, e As EventArgs) ' Код обработки события End Sub |
Быстрое создание мультиязычного сайта на WordPress
В данном видео продемонстрированна возможность создания мультиязычного сайта на WordPress с помощью бесплатного плагина Polylang