Call javascript from vb.net code behind

If DataStore.Record.Exists(theRecord) Then Dim script As String = “alert(‘Record exists’)” If Not Page.ClientScript.IsStartUpScriptRegistered(Me.GetType(), “alertscript”) Then Page.ClientScript.RegisterStartUpScript(Me.GetType(), “alertscript”, script, True) End If End If you would do it like above, where you should replaceDataStore.Record.Exists(theRecord) with condition that checks database record exists

VB.NET Checking if a File is Open before proceeding with a Read/Write?

Private Sub IsFileOpen(ByVal file As FileInfo) Dim stream As FileStream = Nothing Try stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None) stream.Close() Catch ex As Exception If TypeOf ex Is IOException AndAlso IsFileLocked(ex) Then ‘ do something here, either close the file if you have a handle, show a msgbox, retry or as a last resort terminate the … Read more

How do you disable an item in listview control in .net 3.5

You can use the ListBoxItem.ForeColor and UseItemStyleForSubItems properties to make the item look dimmed. Use SystemColors.GrayText to pick the theme color for disabled items. Avoid disabling selection, it prevents the user from using the keyboard. Only disable the checkbox checking. For example: private void listView1_ItemCheck(object sender, ItemCheckEventArgs e) { // Disable checking odd-numbered items if … Read more

Convert to UCS2

Use the following functions to encode unicode string in “UCS2” format: //================> Used to encoding GSM message as UCS2 public static String UnicodeStr2HexStr(String strMessage) { byte[] ba = Encoding.BigEndianUnicode.GetBytes(strMessage); String strHex = BitConverter.ToString(ba); strHex = strHex.Replace(“-“, “”); return strHex; } public static String HexStr2UnicodeStr(String strHex) { byte[] ba = HexStr2HexBytes(strHex); return HexBytes2UnicodeStr(ba); } //================> Used … Read more

How to parse json and read in vb.net

You could use JavaScriptSerializer which is in System.Web.Script.Serialization. Imports System.Web.Script.Serialization Module Module1 Sub Main() Dim s As String Try Dim rawresp As String = “{“”id””:174543706,””first_name””:””Hamed””,””last_name””:””Ap””,””username””:””hamed_ap””,””type””:””private””}” Dim jss As New JavaScriptSerializer() Dim dict As Dictionary(Of String, String) = jss.Deserialize(Of Dictionary(Of String, String))(rawresp) s = dict(“id”) Catch ex As Exception End Try End Sub End Module

Finding all Namespaces in an assembly using Reflection (DotNET)

No, there’s no shortcut for this, although LINQ makes it relatively easy. For example, in C# the raw “set of namespaces” would be: var namespaces = assembly.GetTypes() .Select(t => t.Namespace) .Distinct(); To get the top-level namespace instead you should probably write a method: var topLevel = assembly.GetTypes() .Select(t => GetTopLevelNamespace(t)) .Distinct(); … static string GetTopLevelNamespace(Type … Read more

Regular expression help – comma delimited string

Sounds like you need an expression like this: ^[0-9a-zA-Z]+(,[0-9a-zA-Z]+)*$ Posix allows for the more self-descriptive version: ^[[:alnum:]]+(,[[:alnum:]]+)*$ ^[[:alnum:]]+([[:space:]]*,[[:space:]]*[[:alnum:]]+)*$ // allow whitespace If you’re willing to admit underscores, too, search for entire words (\w+): ^\w+(,\w+)*$ ^\w+(\s*,\s*\w+)*$ // allow whitespaces around the comma

techhipbettruvabetnorabahisbahis forumu