How can i pass values to another webpage and it opens with the passed values
but when i open it does not come with the values
the webpage opens but with empty values when i check in the url field
Imports System.IO
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Imports System.Web.Services
Public Class SearchParent
Inherits System.Web.UI.Page
Dim constr As String = ConfigurationManager.ConnectionStrings("SMIS2022ConnectionString").ConnectionString
Private Shared PageSize As Integer = 25
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
BindDummyRow()
End If
End Sub
Protected Sub BindGridstudent()
'StudentName.Text = Request.QueryString("studentname")
' admno.Text = Request.QueryString("admno")
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand()
cmd.CommandText = "SELECT admno, Name as Names, Class, Stream, Fcount, fhone, Mcount, Mother, ContentType, Data, autoket, Status, Photo
FROM dbo.StudentData order by Name"
cmd.Connection = con
'cmd.Parameters.AddWithValue("@subj", admno.Text.Trim())
'cmd.Parameters.AddWithValue("@term", ddlterm.SelectedItem.Text.Trim())
' cmd.Parameters.AddWithValue("@clas", ddlclass.SelectedItem.Text.Trim())
Dim dtb As New DataTable()
Using sda As New SqlDataAdapter(cmd)
sda.Fill(dtb)
If dtb.Rows.Count > 0 Then
gvFiles.DataSource = Nothing
gvFiles.DataSource = dtb
gvFiles.DataBind()
' SubjectGrdNames.UseAccessibleHeader = True
' SubjectGrdNames.HeaderRow.TableSection = TableRowSection.TableHeader
' If SubjectGrdNames.BottomPagerRow IsNot Nothing Then
'SubjectGrdNames.BottomPagerRow.TableSection = TableRowSection.TableFooter
End If
' End If
End Using
End Using
End Using
End Sub
Protected Sub Upload(sender As Object, e As EventArgs)
Dim company As String = Request.Form(admn0.UniqueID)
Dim k As String = company
Dim f As String = admn0.Text
If String.IsNullOrEmpty(company) Then
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "askConfirmk", "alert('Please you Must Search Student and Click on Select to Upload ... !!')", True)
Exit Sub
End If
If FileUpload1.HasFile Then
Dim fs As Stream = FileUpload1.PostedFile.InputStream
Dim br As New BinaryReader(fs)
Dim bytes As Byte() = br.ReadBytes(DirectCast(fs.Length, Long))
Using Cont As New SqlConnection(constr)
Cont.Open()
Using cmd As New SqlCommand
cmd.Connection = Cont
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "GetPhotoinsertUPDATE"
cmd.Parameters.Add("@p", SqlDbType.Binary).Value = bytes
cmd.Parameters.AddWithValue("@ct", company)
cmd.ExecuteNonQuery()
Cont.Close()
'loaddata()
' Exit Sub
End Using
End Using
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "askConfirmk", "alert('Photo Uploaded Successfully ... !!')", True)
Exit Sub
End If
Response.Redirect(Request.Url.AbsoluteUri)
End Sub
Private Sub BindDummyRow()
Dim dummy As DataTable = New DataTable()
dummy.Columns.Add("Id")
dummy.Columns.Add("admno")
dummy.Columns.Add("Name")
dummy.Columns.Add("Names")
dummy.Columns.Add("Data")
dummy.Columns.Add("Class")
dummy.Columns.Add("Stream")
dummy.Columns.Add("Status")
dummy.Columns.Add("Fhone")
dummy.Columns.Add("Mother")
dummy.Columns.Add("Fcount")
dummy.Columns.Add("Mcount")
dummy.Rows.Add()
gvFiles.DataSource = dummy
gvFiles.DataBind()
End Sub
<WebMethod()>
Public Shared Function GetFiles(ByVal searchTerm As String, ByVal pageIndex As Integer) As String
Dim query As String = "[Files_GetFiles_Pager2000]"
Dim cmd As SqlCommand = New SqlCommand(query)
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandTimeout = "500"
cmd.Parameters.AddWithValue("@SearchTerm", searchTerm)
cmd.Parameters.AddWithValue("@PageIndex", pageIndex)
cmd.Parameters.AddWithValue("@PageSize", PageSize)
cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4).Direction = ParameterDirection.Output
Return GetData(cmd, pageIndex).GetXml()
End Function
Private Shared Function GetData(ByVal cmd As SqlCommand, ByVal pageIndex As Integer) As DataSet
Dim strConnString As String = ConfigurationManager.ConnectionStrings("SMIS2022ConnectionString").ConnectionString
Using con As SqlConnection = New SqlConnection(strConnString)
Using sda As SqlDataAdapter = New SqlDataAdapter()
cmd.Connection = con
sda.SelectCommand = cmd
Using ds As DataSet = New DataSet()
sda.Fill(ds, "Files")
Dim dt As DataTable = New DataTable("Pager")
dt.Columns.Add("PageIndex")
dt.Columns.Add("PageSize")
dt.Columns.Add("RecordCount")
dt.Rows.Add()
dt.Rows(0)("PageIndex") = pageIndex
dt.Rows(0)("PageSize") = PageSize
dt.Rows(0)("RecordCount") = cmd.Parameters("@RecordCount").Value
ds.Tables("Files").Columns.Add("Image")
For i As Integer = 0 To ds.Tables("Files").Rows.Count - 1
If Not IsDBNull(ds.Tables("Files").Rows(i)("Data")) Then
Dim imgBytes As Byte() = CType(ds.Tables("Files").Rows(i)("Data"), Byte())
Dim base64String As String = Convert.ToBase64String(imgBytes, 0, imgBytes.Length)
ds.Tables("Files").Rows(i)("Image") = "data:image/png;base64," & base64String
End If
Next
ds.Tables.Add(dt)
Return ds
End Using
End Using
End Using
End Function
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Response.Redirect(String.Format("~/MenuAcademics.aspx"))
End Sub
Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Using Cont As New SqlConnection(constr)
Cont.Open()
Using cmd As New SqlCommand
cmd.Connection = Cont
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "StudentInsert"
cmd.CommandTimeout = "1000"
' cmd.Parameters.Add("@p", SqlDbType.Binary).Value = bytes
' cmd.Parameters.AddWithValue("@ct", company)
cmd.ExecuteReader()
Cont.Close()
'loaddata()
' Exit Sub
End Using
End Using
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "askConfirmk", "alert('Student Loaded Successfully ... !!')", True)
End Sub
End Class
here is my other code
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="SearchParent.aspx.vb" Inherits="SMIS2022WEB.SearchParent" %>
<!DOCTYPE html>
<head>
<style type="text/css">
.auto-style1 {
width: 39%;
}
.auto-style2 {
width: 187px;
}
.auto-style3 {
width: 190px;
}
</style>
</head>
<form id="form1" runat="server">
<hr />
<asp:FileUpload ID="FileUpload1" runat="server" Visible="False" />
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="Upload" Visible="False" />
<hr />
<asp:Panel ID="Panel1" runat="server">
<table class="auto-style1">
<tr>
<td class="auto-style2">Search:</td>
<td class="auto-style2"> </td>
<td class="auto-style3">
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">
<asp:TextBox ID="txtSearch" runat="server" />
</td>
<td class="auto-style2"> </td>
<td class="auto-style3">
<asp:Button ID="Button3" runat="server" Text="Load Missing Student" />
</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Back To Menu" />
</td>
</tr>
</table>
</asp:Panel>
<hr />
<asp:GridView ID="gvFiles" runat="server" AutoGenerateColumns="False" Height="16px">
<Columns>
<asp:TemplateField HeaderText="admno">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("admno") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("admno") %>'></asp:Label>
<asp:TextBox ID="admno" runat="server" Height="16px" ReadOnly="True" Text='<%# Eval("admno") %>' Width="83px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name" Visible="False">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
</ItemTemplate>
<ItemStyle CssClass="Name" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Student Name">
<EditItemTemplate>
<asp:TextBox ID="TextBox12" runat="server" Text='<%# Bind("Names") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label10" runat="server" Text='<%# Bind("Names") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Class">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Class") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Class") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Stream">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Stream") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Stream") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Status">
<EditItemTemplate>
<asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("Status") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Status") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fcount">
<EditItemTemplate>
<asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("Fcount") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Fcount") %>'></asp:Label>
<br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Father">
<EditItemTemplate>
<asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("Fhone") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("Fhone") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Mother">
<EditItemTemplate>
<asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("Mother") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("Mother") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Mcount">
<EditItemTemplate>
<asp:TextBox ID="TextBox10" runat="server" Text='<%# Bind("Mcount") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("Mcount") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Photo">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("Data") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Image ID="Image1" runat="server" Height="25px" ImageUrl='<%# Eval("Data") %>' Width="25px" />
</ItemTemplate>
</asp:TemplateField>
<asp:ButtonField CommandName="Select" HeaderText="Select" Text="Select" />
<asp:TemplateField HeaderText="dd">
<EditItemTemplate>
<asp:TextBox ID="TextBox11" runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<a href="#" onclick="window.open('ShowDetails.aspx?admno=<%#Eval("admno").ToString() + "&studentname=" + Eval("name").ToString() %> ','PrintMe','height=400px,width=800px,scrollbars=1');">LinkView</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<div class="Pager"></div>
<hr />
<div id="dialog" style="display: none">
</div>
<script src="../Scripts/jquery-1.8.3.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/themes/start/jquery-ui.css" />
<script type="text/javascript" src="../Scripts/1.8.24 jquery.js"></script>
<script src="../Scripts/ASPSnippets_Pager.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
GetCustomers(1);
$("body").on("keyup", "[id*=txtSearch]", function () {
GetCustomers(parseInt(1));
});
$("body").on("click", ".Pager .page", function () {
GetCustomers(parseInt($(this).attr('page')));
});
$("#dialog").dialog({
autoOpen: false,
modal: true,
height: 300,
width: 300,
title: "Zoomed Image"
});
$('body').on('click', "[id*=Image1],[id*=gvFiles] .imgData", function () {
$('#dialog').html('');
$('#dialog').append($(this).clone());
$('#dialog img').css('height', '250');
$('#dialog img').css('width', '260');
$('#dialog').dialog('open');
});
});
function SearchTerm() {
return jQuery.trim($("[id*=txtSearch]").val());
};
function GetCustomers(pageIndex) {
$.ajax({
type: "POST",
url: "SearchParent.aspx/GetFiles",
data: '{searchTerm: "' + SearchTerm() + '", pageIndex: ' + pageIndex + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});
}
var row;
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var files = xml.find("Files");
if (row == null) {
row = $("[id*=gvFiles] tr:last-child").clone(true);
}
$("[id*=gvFiles] tr").not($("[id*=gvFiles] tr:first-child")).remove();
if (files.length > 0) {
$.each(files, function () {
var employee = $(this);
$("td", row).eq(0).html($(this).find("admno").text());
$("td", row).eq(1).html($(this).find("Names").text());
$("td", row).eq(2).html($(this).find("Class").text());
$("td", row).eq(3).html($(this).find("Stream").text());
$("td", row).eq(4).html($(this).find("Status").text());
$("td", row).eq(5).html($(this).find("Fcount").text());
$("td", row).eq(6).html($(this).find("Fhone").text());
$("td", row).eq(7).html($(this).find("Mother").text());
$("td", row).eq(8).html($(this).find("Mcount").text());
$("td", row).eq(9).html("<img class='imgData' src='" + $(this).find("Image").text() + "' alt='" + "' height='25px' width='25px' />");
$("td", row).eq(10).html("<a href='javascript:;' onclick='GetData(this)'>Select</a>");
$("[id*=gvFiles]").append(row);
row = $("[id*=gvFiles] tr:last-child").clone(true);
});
var pager = xml.find("Pager");
$(".Pager").ASPSnippets_Pager({
ActiveCssClass: "current",
PagerCssClass: "pager",
PageIndex: parseInt(pager.find("PageIndex").text()),
PageSize: parseInt(pager.find("PageSize").text()),
RecordCount: parseInt(pager.find("RecordCount").text())
});
$(".Name").each(function () {
var searchPattern = new RegExp('(' + SearchTerm() + ')', 'ig');
$(this).html($(this).text().replace(searchPattern, "<span class = 'highlight'>" + SearchTerm() + "</span>"));
});
} else {
var empty_row = row.clone(true);
$("td:first-child", empty_row).attr("colspan", $("td", row).length);
$("td:first-child", empty_row).attr("align", "center");
$("td:first-child", empty_row).html("No records found for the search criteria.");
$("td", empty_row).not($("td:first-child", empty_row)).remove();
$("[id*=gvFiles]").append(empty_row);
}
};
function GetData(ele) {
var row = $(ele).closest('tr');
var id = $("td", row).eq(0).html();
var idt = $("td", row).eq(3).html();
var named = $("td", row).eq(1).html();
$('[id*=admn0]').val(id);
$('[id*=Names]').val(named);
$("[id*=Image1]").attr('src', $("td", row).find('.imgData').attr('src'));
};
</script>
<asp:Image ID="Image2" runat="server" Height="70px" Width="86px" Visible="False" />
<br />
<asp:TextBox ID="admn0" runat="server" ReadOnly="True" Visible="true" Width="111px"></asp:TextBox>
<br />
<asp:TextBox ID="Names" runat="server" ReadOnly="True" Visible="true" Width="111px"></asp:TextBox>
</form>