Click here to Skip to main content
16,011,855 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here I want to show that when a=o than message box show the message, if not the delete is work. But Locally is all right but when it uploaded into server than message is not working.

VB
Dim qu As String = "select [ReportType_ID] from [Report]"
            Dim da As SqlDataAdapter = New SqlDataAdapter(qu, conn)
            Dim dt As DataTable = New DataTable()
            da.Fill(dt)
            Dim start As Integer = 0
            Dim Endvalue As Integer = dt.Rows.Count - 1



            If (Endvalue >= 0) Then


                For value As Integer = start To Endvalue
                    Dim o As String
                    Dim a As String
                    'o = dt.Rows.Item(i).Item("ReportType_ID")
                    o = dt.Rows.Item(value).Item("ReportType_ID")

                    a = gvList.DataKeys(e.RowIndex).Value.ToString

                    If (a = o) Then
                        MessageBox.Show("Data Exist In Main Report! So, you can't delete from here.")
                        Response.Redirect("ReportType.aspx")
                        Exit For

                    End If

                Next value

'DELETE

                clsReportType.DeleteReportType(gvList.DataKeys(e.RowIndex).Value)
                Dim strJs As String = "<script>alert('Record Deleted Successfully..');</script>"
                ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(Page), "alert", strJs, False)
                ObjReportType.SelectCountMethod = "GetAllReportType"
                e.Cancel = True
            Else
               

            End If

        End Using
Posted
Updated 20-Sep-11 23:58pm
v2

Hello Rohit,

I got your message and use it for your requirement.

C#
protected void Page_Load(object sender, EventArgs e)
   {
       const string someScript = "alertMe";
       if (!ClientScript.IsStartupScriptRegistered(this.GetType(), someScript))
       {
           ClientScript.RegisterStartupScript(this.GetType(),
               someScript, "alert('I was called from Content page!')", true);
       }
   }
 
Share this answer
 
Comments
Rohit Sharma706 22-Sep-11 5:41am    
Sir don't mind i totally confuse.can you told How to applied that.
This is my vb page

Protected Sub gvList_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles gvList.RowDeleting
Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("AnimalHusbandry").ConnectionString)
Try






Dim qu As String = "select [FormType_ID] from [Forms]"
Dim da As SqlDataAdapter = New SqlDataAdapter(qu, conn)
Dim dt As DataTable = New DataTable()
da.Fill(dt)
Dim start As Integer = 0
Dim Endvalue As Integer = dt.Rows.Count - 1

If (Endvalue >= 0) Then

For value As Integer = start To Endvalue
Dim o As String
Dim a As String
'o = dt.Rows.Item(i).Item("ReportType_ID")
o = dt.Rows.Item(value).Item("FormType_ID")

a = gvList.DataKeys(e.RowIndex).Value.ToString

If (a = o) Then
'Dim strscript As String = "<script>alert('Record Deleted Successfully..');</script>"
' ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(Page), "alert", strscript, False)

' MessageBox.Show("Data Exist In Main Form! So, you can't delete from here.")
' MsgBox("Data Exist In Main Form! So, you can't delete from here.")
'Response.Write("<script language = 'javascript'>alert('the flag was succesful() ');</script>")
' Dim strScript As String = "<script language='javascript' id=’myClientScript’>test();</script>"
'Page.RegisterStartupScript("callTest", strScript)
'Dim strJs As String = "<script>alert('Record Deleted Successfully..');</script>"
'ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(Page), "alert", strJs, False)
'e.Cancel = True
'ObjFormType.SelectCountMethod = "GetAllFormType"
gvList.Attributes.Add("OnClientClick", "javascript:computeCorrectValue()")

'Dim script As String = String.Format("alert('this is alert');")
'ScriptManager.RegisterClientScriptBlock(Page, GetType(System.Web.UI.Page), "redirect", script, True)
'Dim BuildScript As New System.Text.StringBuilder


'BuildScript.Append("<script>")
'BuildScript.Append(Environment.NewLine)
'BuildScript.Append("alert('heLLO');")
'BuildScript.Append(Environment.NewLine)
'BuildScript.Append("")


'Page.RegisterStartupScript("MsgBoxJS", BuildScript.ToString())

Response.Redirect("FormType.aspx", False)

Exit For
Else

End If
Next value
clsFormType.DeleteFormType(gvList.DataKeys(e.RowIndex).Value)
Dim str As String = "<script>alert('Record Deleted Successfully..');</script>"
ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(Page), "alert", str, False)
ObjFormType.SelectCountMethod = "GetAllFormType"

e.Cancel = True
Else


End If


Catch ex As Exception
MsgBox(ex.Message)

End Try

End Using




' Response.Redirect("FormType.aspx")

'clsFormType.DeleteFormType(gvList.
Welcome Rohit,

You can use script Alerts to use showing Message on the Web.
 
Share this answer
 
Comments
Rohit Sharma706 22-Sep-11 4:12am    
yes sir i try that one.but try that after showing message it Response.Redirect("ReportType.aspx").In that case give the error "Thread was being aborted".


I try that like

If (a = o) Then
Dim str As String = "<script>alert('Record Deleted Successfully..');</script>"
ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(Page), "alert", str, False)
Response.Redirect("ReportType.aspx")

but It Give error "Thread was being aborted".
Hello Rohit,

Actually Windows.Form,Windows.Graphics is not supported in Server Concept.

For doing this operation you should need to build your application to WPF.




Best Regard
Anubhava Dimri
+91 9250168195
 
Share this answer
 
Comments
Rohit Sharma706 22-Sep-11 0:51am    
Thanks for reply sir,Now my confusion is clear.
But sir i don't no WPF.so,can you give me any alternative way to show this message.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900